2 min to read.
ERC-20
The technical standard for fungible tokens on Ethereum, defining a common set of functions every such token implements.
What is ERC-20?
ERC-20 is the technical standard for fungible tokens on Ethereum, meaning tokens in which every unit is interchangeable with every other. It specifies a common set of functions that a token's smart contract must provide, so that wallets, exchanges and applications can handle any ERC-20 token in the same way.
How it works
An ERC-20 token is a smart contract that keeps a table of balances: which address holds how many units. The standard defines functions including:
- totalSupply: the number of tokens in existence.
- balanceOf: the balance of a given address.
- transfer: send tokens from the caller to another address.
- approve and allowance: let another address, usually a contract, spend a set amount on the owner's behalf.
- transferFrom: used by the approved spender to move those tokens.
The contract also emits standard events so that software can follow transfers. Sending a token is a transaction on Ethereum, and the fee is paid in ether, not in the token.
Example
Many stablecoins are ERC-20 tokens. When a user swaps one on a decentralised exchange, the wallet first asks to approve the exchange contract, then the exchange calls transferFrom to collect the tokens and sends the other asset in return.
Why it matters
The standard was proposed in 2015 and made it simple to create tokens that work everywhere on Ethereum from day one. It underpins stablecoins, governance tokens and DeFi, and the same interface is used on other Ethereum-compatible networks.
Risks and misunderstandings
- Anyone can create an ERC-20 token with any name and symbol. Compliance with the standard says nothing about a project's quality or honesty, and fake copies of known tokens are common.
- Approvals stay in force until revoked. An unlimited approval given to a malicious or flawed contract can be used to drain that token from the wallet.
- Tokens sent to a contract that cannot handle them can be stuck permanently.
- Ether itself is not an ERC-20 token, which is why a wrapped version exists.