- Implement the
IFeeCurrencyinterface — the token must extend ERC20 with the functions the Celo blockchain uses to debit and credit gas fees. This step is the responsibility of the token issuer. - Register the token through governance — the token must be added to the on-chain allowlist via a governance proposal. The Celo team can support you through this step.
Step 1: Implement the IFeeCurrency Interface
This step must be completed by the token issuer — every project implements and maintains its own fee currency token.The IFeeCurrency Interface
Fee currencies must implement the IFeeCurrency interface, which extends ERC20 with two additional functions used by the Celo blockchain to debit and credit gas fees. When a CIP-64 transaction is executed:- Before execution — the blockchain calls
debitGasFeesto reserve the maximum gas the transaction can spend - After execution — the blockchain calls
creditGasFeesto refund unused gas and distribute fees to the appropriate recipients
debitGasFees
- Must deduct
valuefromfrom’s balance - Must revert if
msg.senderis notaddress(0)(only the VM may call this)
creditGasFees
There are two versions ofcreditGasFees. Both should be implemented for compatibility.
New signature (used once all fee currencies have migrated):
- Must credit each
recipientthe correspondingamount - Must revert if
msg.senderis notaddress(0) - Must revert if
recipientsandamountshave different lengths
_gatewayFeeRecipientand_gatewayFeeAmountare deprecated and will always be zero- Must revert if
msg.senderis notaddress(0)
Example Implementation
The following example from celo-org/fee-currency-example shows a minimal fee currency token using OpenZeppelin’s ERC20 with burn/mint mechanics for gas fee handling:_burn in debitGasFees and _mint in creditGasFees to handle the gas fee lifecycle. The onlyVm modifier ensures only the blockchain itself (via address(0)) can call these functions.
Testing
Use Foundry to test your fee currency implementation. The fee-currency-example repository includes a test suite you can use as a starting point:debitGasFeescorrectly reduces the sender’s balancedebitGasFeesreverts when called by any address other thanaddress(0)- Both
creditGasFeessignatures correctly credit all recipients creditGasFeesreverts when called by any address other thanaddress(0)- The total debited amount equals the total credited amount across a transaction lifecycle
Step 2: Register Through Governance
Once your token implementsIFeeCurrency, it must be added to the on-chain allowlist in FeeCurrencyDirectory.sol through a governance proposal. The governance process ensures that fee currencies meet the necessary requirements for network stability.
Unlike step 1, you don’t have to navigate this step alone — the Celo team can support you through the governance process. Reach out on the Celo Discord server to get started.
If your token uses decimals other than 18, you will also need to deploy an adapter contract. See Adapters for Non-18-Decimal Tokens for details.