ContractKit has been sunset for external use. Please use viem or wagmi for connecting with the blockchain.Check out the migration guide for updating your dapp from ContractKit to viem.To learn more visit the Celo forum.
Setting Default Tx Options
kit
allows you to set default transaction options:
Set feeCurrency
for a transaction
You can set the feeCurrency
for each transaction individually by setting the feeCurrency
field in the .send()
method. The feeCurrency
field accepts contract addresses of whitelisted fee currencies.
Getting the Total Balance
This method from thekit
will return the CELO, locked CELO, cUSD and total balance of the address
Deploy a contract
Deploying a contract with the default account already set. Simply send a transaction with noto:
field. See more about sending custom transactions below.
You can verify the deployment on the Alfajores block explorer here. Wait for the receipt and log it to get the transaction details.
Sending Custom Transactions
The Celo transaction object is not the same as Ethereum’s. There is a new optional field present:feeCurrency
(address of the ERC20 contract to use to pay for gas)
feeCurrency
enables transaction fees to be paid in currencies other than CELO. The currently supported fee currencies are CELO, cUSD and cEUR. You can specify the currency by passing the contract address of the currency you would like the transaction fees to be paid in.
Celo accepts original Ethereum type transactions as well, so you can use Ethereum signing tools (like Metamask) as well as Celo specific wallets and tools. You can read more about these transaction formats in CIP 35.
For a raw transaction:
Interacting with Custom contracts
You can use ContractKit to interact with any deployed smart contract, provided you have the contract address and the ABI. To do so, you will initialize a newweb3
Contract instance. Then you can call functions on the contract instance to read state or send transactions to update the contract. You can see some code snippets below.