feeCurrency property in the transaction object. The feeCurrency property in the transaction object is exclusive to Celo and allows paying gas fees using assets other than the native currency of the network.
The below steps describe how wallets can implement the alternate fee currency feature in order to allow users to use alternate assets in the user’s wallet to pay for gas fees.
Fee Currency Field
The protocol maintains a governable allowlist of smart contract addresses which can be used to pay for transaction fees. These smart contracts implement an extension of the ERC20 interface, with additional functions that allow the protocol to debit and credit transaction fees. When creating a transaction, users can specify the address of the currency they would like to use to pay for gas via thefeeCurrency field. Leaving this field empty will result in the native currency, CELO, being used. Note that transactions that specify non-CELO gas currencies will cost approximately 50k additional gas.
Allowlisted Gas Fee Addresses
To obtain a list of the gas fee addresses that have been allowlisted using Celo’s Governance Process, you can run thegetCurrencies() method on the FeeCurrencyDirectory contract. All other notable Mainnet core smart contracts are listed here.
You can also query the available tokens with celocli:
Tokens with Adapters
After Contract Release 11, addresses in the allowlist are no longer guaranteed to be full ERC20 tokens and can now also be adapters. Adapters are allowlisted in-lieu of tokens in the scenario that a ERC20 token has decimals other than 18 (e.g. USDT and USDC). The Celo Blockchain natively works with 18 decimals when calculating gas pricing, so adapters are needed to normalize the decimals for tokens that use a different one. Some stablecoins use 6 decimals as a standard. Transactions with those ERC20 tokens are performed as usual (using the token address), but when paying gas currency with those ERC20 tokens, the adapter address should be used. This adapter address is also the one that should be used when querying Gas Price Minimum. Adapters can also be used to querybalanceOf(address) of an account, but it will return the balance as if the token had 18 decimals and not the native ones. This is useful to calculate if an account has enough balance to cover gas after multiplying gasPrice * estimatedGas without having to convert back to the token’s native decimals.
To learn more about gas pricing, see Gas Pricing.
Adapters by network
Mainnet
Celo Sepolia (testnet)
Using Fee Abstraction with Celo CLI
Transfer 1 USDC using USDC as fee currency, with thecelocli using the --gasCurrency flag
Enabling Transactions with ERC20 Token as fee currency
We recommend using viem as it has support for thefeeCurrency field in the transaction required for sending transactions where the gas fees will be paid in ERC20 tokens. Ethers.js and web.js currently don’t support feeCurrency.
Estimating gas price
To estimate gas price use the token address (in case of USDm, EURm and BRLm) or the adapter address (in case of USDC and USDT) as the value for feeCurrency field in the transaction.The Gas Price Minimum value returned from the RPC has to be interpreted in 18 decimals.
Preparing a transaction
When preparing a transaction that uses ERC20 token for gas fees, use the token address (in case of USDm, EURm and BRLm) or the adapter address (in case of USDC and USDT) as the value forfeeCurrency field in the transaction.
The recommended transaction type is 123, which is a CIP-64 compliant transaction read more about it here.
Here is how a transaction would look like when using USDC as a medium to pay for gas fees.
To get details about the underlying token of the adapter you can call
adaptedToken function on the adapter address, which will return the underlying token address.Sending transaction using Fee Abstraction
Sending transaction with fee currency other than the native currency of the network is pretty straightforward all you need to do is set thefeeCurrency property in the transaction object with the address of the token/adapter you want to use to pay for gas fees.
The below code snippet demonstrates transferring 1 USDC using USDC as gas currency.