ERC-20

Smart Contract Updated Feb 2026

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:

  1. Approve: You call approve(Uniswap's router, amount) — allowing Uniswap to spend your tokens
  2. 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:

TokenDecimalsMinimum UnitExample
USDC60.000001 USDC100 USDC = 100000000
ETH (WETH)180.000000000000000001 ETH1 ETH = 1000000000000000000
WBTC80.00000001 WBTC1 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:

ExtensionEIPPurposeExamples
BurnableEIP-20++Holders can permanently destroy tokensBNB, SHIB
Mintable-Owner can create new tokensUSDC (Circle mints)
Pausable-Owner can freeze all transfersBNB, USDT
Capped-Maximum supply limit-
Permit (EIP-2612)EIP-2612Gasless approvals via signatureDAI, UNI
Flash MintableEIP-3156Flash loans for the tokenDAI
TokenSymbolUse CaseSupply
TetherUSDTStablecoin (fiat-backed)$100B+
USD CoinUSDCStablecoin (fiat-backed)$40B+
ChainlinkLINKOracle network payment600M
UniswapUNIGovernance1B
DaiDAIStablecoin (crypto-backed)5B
Wrapped BTCWBTCBitcoin on Ethereum150K BTC
AaveAAVEGovernance + staking15M

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.