Viem
Viem is full featured lightweight javascript library for interacting with EVM chains with first class support for Celo. Viem is used by Wagmi and Rainbowkit. The Viem docs have excellent examples of how to use it in your project.With Celo
The TLDR is that passing a celo chain fromviem/chains
into the config of createWalletClient
will enable any function that signs a transaction including sendTransaction
and writeContract
to accept feeCurrency
in its parameters object. Donāt care about feeCurrency? Leave it out to pay with CELO.
Gas Price
When paying for transaction with an alternate feeCurrency token it is important to know the price of gas denominated in that token. As such Celo nodes accept an optional param of the address of the token for theeth_gasPrice
call. Therefore rather than use viemās publicClient.getGasPrice()
function you should fetch it like the example.