What is ERC-20?
ERC-20 is the technical standard for fungible (interchangeable) tokens on Ethereum and other EVM-compatible blockchains. It defines a set of rules that every token contract must follow, ensuring that tokens work consistently across wallets, DEXs, and dApps.
Fungible means each token is identical — 1 USDC is the same as any other 1 USDC, just like a dollar bill. This is in contrast to NFTs (ERC-721), where each token is unique.
ERC-20 was proposed by Fabian Vogelsteller in November 2015 (EIP-20) and has become the most widely used token standard in crypto. There are over 1 million ERC-20 contracts deployed on Ethereum, including major tokens like USDT, USDC, LINK, UNI, and SHIB.
The ERC-20 Interface
Every ERC-20 token must implement these functions:
Core Functions
// Token information
function name() public view returns (string) // "USD Coin"
function symbol() public view returns (string) // "USDC"
function decimals() public view returns (uint8) // 6
// Supply
function totalSupply() public view returns (uint256) // 1000000000000
// Balance & Transfer
function balanceOf(address) public view returns (uint256)
function transfer(address to, uint256 amount) public returns (bool)
function transferFrom(address from, address to, uint256 amount) public returns (bool)
// Allowance (Approve spending)
function approve(address spender, uint256 amount) public returns (bool)
function allowance(address owner, address spender) public view returns (uint256)
Events
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
Why Standardization Matters
Because every ERC-20 token implements the same interface:
- Wallets (MetaMask) can display any token without custom code
- DEXs (Uniswap) can list any token automatically
- Block explorers (Etherscan) can track any token
- Developers don’t need to learn each token’s custom interface
Imagine if every bank had a different way to check balances and make transfers — that’s what crypto would be like without ERC-20.
How ERC-20 Transfers Work
Direct Transfer
Alice wants to send 100 USDC to Bob
Alice calls: USDC.transfer(Bob's address, 100 * 10^6)
Result: Bob's balance increases by 100 USDC
Approved Transfer (For DEX interactions)
When you swap tokens on Uniswap, the process is:
- Approve: You call
approve(Uniswap's router, amount)— allowing Uniswap to spend your tokens - Swap: You call Uniswap’s swap function, which calls
transferFrom(your address, pool, amount)to move your tokens
This two-step process is why your first DEX swap requires an approval transaction (costing gas) before the actual swap.
Decimals
ERC-20 tokens use integer math (blockchains can’t handle decimals). The decimals field defines how many decimal places the token supports:
| Token | Decimals | Minimum Unit | Example |
|---|---|---|---|
| USDC | 6 | 0.000001 USDC | 100 USDC = 100000000 |
| ETH (WETH) | 18 | 0.000000000000000001 ETH | 1 ETH = 1000000000000000000 |
| WBTC | 8 | 0.00000001 WBTC | 1 WBTC = 100000000 |
Most tokens use 18 decimals (matching ETH’s base unit, wei). Stablecoins often use 6 decimals to match traditional currency precision.
Common ERC-20 Extensions
Many tokens add optional features on top of the base standard:
| Extension | EIP | Purpose | Examples |
|---|---|---|---|
| Burnable | EIP-20++ | Holders can permanently destroy tokens | BNB, SHIB |
| Mintable | - | Owner can create new tokens | USDC (Circle mints) |
| Pausable | - | Owner can freeze all transfers | BNB, USDT |
| Capped | - | Maximum supply limit | - |
| Permit (EIP-2612) | EIP-2612 | Gasless approvals via signature | DAI, UNI |
| Flash Mintable | EIP-3156 | Flash loans for the token | DAI |
Popular ERC-20 Tokens
| Token | Symbol | Use Case | Supply |
|---|---|---|---|
| Tether | USDT | Stablecoin (fiat-backed) | $100B+ |
| USD Coin | USDC | Stablecoin (fiat-backed) | $40B+ |
| Chainlink | LINK | Oracle network payment | 600M |
| Uniswap | UNI | Governance | 1B |
| Dai | DAI | Stablecoin (crypto-backed) | 5B |
| Wrapped BTC | WBTC | Bitcoin on Ethereum | 150K BTC |
| Aave | AAVE | Governance + staking | 15M |
ERC-20 Security Considerations
The Approve Trap
When you approve a contract to spend your tokens, the approval remains until you revoke it. If you approve a malicious contract, it can drain your tokens later.
Best practice: Only approve the exact amount needed, or revoke approvals after use. Check active approvals on tools like Etherscan Token Approval Checker or Revoke.cash.
Front-running Approvals
Since approvals are on-chain transactions, they’re visible in the mempool. MEV bots can front-run large approvals, though this is less common than sandwich attacks on swaps.
Deflationary/Ilationary Tokens
Some ERC-20 tokens have transfer fees (e.g., 1% burned per transfer). These can break DEX integrations because the DEX expects to receive the full amount but receives less. Uniswap and other DEXs have added support for “fee-on-transfer” tokens, but many older integrations don’t handle this correctly.
Frequently Asked Questions
Q: What’s the difference between a coin and a token? A: A coin has its own blockchain (BTC, ETH, SOL). A token is built on top of an existing blockchain using a standard like ERC-20. USDC is a token on Ethereum; ETH is the native coin.
Q: Can I create my own ERC-20 token? A: Yes. Tools like OpenZeppelin Wizard let you generate a secure ERC-20 contract in minutes. Deploying it costs gas (~$50-200 on Ethereum, <$1 on L2s).
Q: Why does my swap need two transactions? A: First transaction approves the DEX to spend your tokens. Second transaction executes the swap. You can avoid this by using “infinite approval” (approve once for a very large amount), but this is less secure.