Skip to main content

ERC-20 interaction

Standard ERC-20 contracts work on Sei without modification. This page shows the common read and write operations with viem and ethers.

Try it: deploy an ERC-20

Compile and deploy a real ERC-20 to Sei Testnet from the browser. The Remix sandbox preloads an OpenZeppelin-based DemoToken. Then use the read and write patterns below with your deployed address. First, add Sei Testnet to your wallet: In Remix, compile the contract on the Solidity Compiler tab. Then deploy it from the Deploy & Run tab with Environment set to Injected Provider - MetaMask.

Setup

Reading token metadata

Reading balances and allowances

Transferring tokens

Approving a spender

Watching transfer events

Watch new events over the WebSocket endpoint. Watchers that poll the public HTTP endpoint can miss events or report them twice. For details, see Listen to events.

Fetching historical transfers

The public endpoints return logs for at most 2,000 blocks per request, so query a bounded range. This example reads the latest 2,000 blocks:
To go further back, request consecutive ranges of 2,000 blocks or fewer, or use an indexer.

CosmWasm token compatibility

CW20 tokens on Sei have ERC-20 pointer contracts that expose the standard ERC-20 interface. You can use all of the patterns above with a CW20 pointer address. To look up the pointer address, see Pointer Contracts.