ERC-20 Interface Reference — Functions & Events

ERC-20 is the fungible-token standard on EVM chains. This reference lists the standard functions and events that a compliant token contract exposes.

Metadata functions

name — the human-readable token name. symbol — the short ticker. decimals — the number of decimal places the token uses when displaying balances. totalSupply — the total amount of tokens in existence. These are read-only views and are optional in the strictest reading of the standard, though nearly all tokens implement them.

Balance and transfer functions

balanceOf(owner) — returns the token balance of an address, expressed in the smallest unit. transfer(to, amount) — moves amount from the caller to to. transferFrom(from, to, amount) — moves amount from from to to, spending an allowance the caller was granted.

Allowance functions

approve(spender, amount) — authorizes spender to withdraw up to amount from the caller's balance. allowance(owner, spender) — returns the remaining amount spender is still allowed to withdraw from owner. This approve-then-transferFrom pattern lets contracts move tokens on a user's behalf.

Events

Transfer(from, to, value) — emitted on every token movement, including mints (from the zero address) and burns (to the zero address). Approval(owner, spender, value) — emitted when an allowance is set. Both from/to/owner/spender are indexed, so you can filter logs by address with eth_getLogs.

常见问题

Are token amounts in ERC-20 stored with decimals applied?

No. Balances and transfer amounts are stored as integers in the smallest unit. To display a human amount you divide by 10 to the power of decimals. For a token with 18 decimals, one whole token is 10^18 base units.

How do I detect all transfers of a token?

Subscribe to or query the Transfer event with eth_getLogs, filtering by the token contract address and the Transfer signature topic. Because from and to are indexed, you can further filter by a specific wallet address.

相关工具

充值、拿密钥、上线。

自助开通。支持加密货币或银行卡。按额度计费——重型原语更贵,简单调用很便宜。

获取 API 密钥