Skip to main content

Overview

The ERC20 precompile provides a standard ERC20-compliant interface that allows EVM tooling and libraries to interact with native Cosmos SDK tokens stored in the bank module as if they were standard ERC20 tokens. Each registered token pair gets its own unique precompile contract address that directly interfaces with the bank module - no token conversion or wrapping occurs. All balances, transfers, and operations work directly on the native bank module token balances. Address: Dynamic (assigned per token pair registration) Related Module: x/erc20

Gas Costs

Gas costs are approximated and may vary based on token complexity and chain settings.

Token Pair Registration

The ERC20 precompile works through a token pair registration system:
  1. Native Cosmos Token: Each Cosmos SDK denomination (e.g., test, atest) exists as a native token in the bank module
  2. ERC20 Interface: A corresponding ERC20 precompile contract provides an interface at a unique address
  3. Direct Bank Module Access: The ERC20 interface operates directly on bank module balances - there is no separate ERC20 token state
  4. Dynamic Addresses: Each token pair gets its own precompile address when registered
The precompile address is deterministically generated based on the token denomination. Query the x/erc20 module to find the precompile address for a specific token.

Methods

totalSupply

Returns the total amount of tokens in existence.

balanceOf

Returns the token balance of a specified account.

transfer

Moves tokens from the caller’s account to a recipient.

transferFrom

Moves tokens from one account to another using an allowance.

approve

Sets the allowance of a spender over the caller’s tokens.

allowance

Returns the remaining number of tokens that a spender is allowed to spend on behalf of an owner.

name

Returns the name of the token.

symbol

Returns the symbol of the token.

decimals

Returns the number of decimals used for the token.
Decimal Handling: The ERC20 precompile may need to handle complex decimal conversions between Cosmos native tokens and ERC20 representation. Some Cosmos tokens use 6 decimals (e.g., test) while ERC20 typically uses 18. Always verify the decimal count for accurate amount calculations.

Full Solidity Interface & ABI

ERC20 Solidity Interface
ERC20 ABI