Skip to main content
As of block height 31,056,500 (March 26, 2025, 3:00 AM UTC), Celo is no longer a standalone Layer 1 blockchain—it is now an Ethereum Layer 2! Some documentation may be outdated as updates are in progress. If you encounter issues, please file a bug report.For the most up-to-date information, refer to our Celo L2 documentation.
Hello devs 🌱 this is a migration path away from contractkit. This aims to give examples to help you move to viem.

Initialization

Basic usage

While we cannot here show all the use-cases of contrackit or ethers or viem, let’s try to give an overview of how they can be used for different goals.

Get address

With viem:

Get wallet

With viem:

Provider methods

Signer methods

Contract interaction

I’ll show the most “basic” interaction, which is a transfer. On CELO, it comes with a twist, you can transfer 4 currencies, CELO, USDm, EURm, and BRLm. You can get the addresses on these tokens by heading to the explorer and getting their abi and addresses, or you can also use our registry contract. You can also use the @celo/abis package to get the ABIs directly.

Balance

Transfer

Then, use the address of the token that you need and call the transfer method of the contract.

Multicall

While contractkit didn’t directly support multicall, you could use libraries such as @dopex-io/web3-multicall as such:
You now can use viem directly to multicall since they have the address configured in the viem/chains files.

Fee Currency

With Viem’s built in Celo transaction serializer and Celo block/transaction formatters it is easy to build a wallet that supports Celo’s ability to pay gas fees with various erc20 tokens. Simply, import a Celo chain from viem/chain and pass it to Viem’s createWalletClient. Once the client is created you can add the feeCurrency field to your transaction with the address of the token you want to use for gas.

Further reading

For more in depth examples and documentation about viem specifically, I highly recommend checking out the extensive documentations of viem. Another interesting application to help you migrate could be StCelo-v2. You can checkout the changes going from react-celo + contractkit to rainbowkit + wagmi + viem in this pull-request.