Skip to main content

Overview

The ERC20 precompile provides standard ERC20 token functionality for native Cosmos tokens that have been registered for EVM compatibility. Each registered token pair gets its own unique precompile contract address. This allows for seamless interaction with native Cosmos assets through familiar ERC20 interfaces. 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 Mapping

The ERC20 precompile works through a token pair mapping system:
  1. Native Cosmos Token: Each Cosmos SDK denomination (e.g., test, stake) exists as a native token
  2. ERC20 Contract: A corresponding ERC20 precompile contract is created at a unique address
  3. Bidirectional Conversion: Tokens can be converted between native and ERC20 representations
  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