ERC-20

ERC-20

 定义

ERC-20 (Ethereum Request for Comment 20) is the most important token standard in the history of cryptocurrency, defining the common interface that all 代币 on Ethereum must implement. Proposed by Fabian Vogelsteller and Vitalik Buterin in November 2015 and finalized as EIP-20, ERC-20 established six mandatory functions (`transfer`, `transferFrom`, `approve`, `allowance`, `balanceOf`, `totalSupply`) and two optional fields (`name`, `symbol`) that all compliant tokens must expose. This standardization was revolutionary: any wallet, exchange, DeFi protocol, or 聪明的合同 that understands the ERC-20 interface can work with any ERC-20 token without custom integration — enabling the interoperable, composable DeFi ecosystem. Every major token — USDC, USDT, LINK, UNI, AAVE, DAI, SHIB, and thousands more — is an ERC-20 token. The standard unlocked the ICO boom of 2017, the DeFi explosion of 2020, and remains the foundational primitive of the entire Ethereum token economy, with cumulative ERC-20 transaction volume exceeding trillions of dollars.

起源与历史

日期创建
2015年XNUMX月XNUMX日Fabian Vogelsteller proposes EIP-20 on Ethereum GitHub
2017年XNUMX月ERC-20 formally standardized; ICO boom leverages it — $5.6B raised in 2017 via ERC-20 tokens
2018Virtually all new token projects launch as ERC-20; ecosystem reaches 100,000+ tokens
2020DeFi Summer: ERC-20 tokens power Uniswap, Compound, Aave, Yearn — $1B+ locked
2021Stablecoins (USDC, USDT ERC-20 version) dominate; ERC-20 transfer volume exceeds BTC
2022ERC-20 token market cap exceeds $200B; hundreds of billions in daily transfer volume
2023ERC-20 remains dominant; 500,000+ unique ERC-20 token contracts deployed
 “ERC-20 is the most successful open source specification ever created. It enables every token to speak the same language.”
Fabian Vogelsteller, creator of ERC-20

运作模式

“` ERC-20 Mandatory Interface:

function totalSupply() → uint256 function balanceOf(address) → uint256 function transfer(address to, uint amount) → bool function transferFrom(address from, address to, uint amount) → bool function approve(address spender, uint amount) → bool function allowance(address owner, address spender) → uint256

Events: event Transfer(address indexed from, address indexed to, uint256 value) event Approval(address indexed owner, address indexed spender, uint256 value)

How transfer works: Alice sends 100 USDC to Bob:

  1. Alice calls USDC.transfer(Bob, 100)
  2. Contract checks: balances[Alice] >= 100
  3. balances[Alice] -= 100
  4. balances[Bob] += 100
  5. emit Transfer(Alice, Bob, 100)

How approve/transferFrom works (DeFi pattern):

  1. Alice calls USDC.approve(UniswapRouter, 1000)
  2. UniswapRouter can now spend up to 1000 USDC on Alice’s behalf
  3. Router calls USDC.transferFrom(Alice, Pool, 1000)
功能目的Who Calls It
`totalSupply()`Returns total token countAnyone (view)
`balanceOf(addr)`Returns address’s balanceAnyone (view)
`transfer(to, amt)`Send tokens from callerToken holder
`approve(spender, amt)`Authorize spenderToken holder
`transferFrom(from, to, amt)`Transfer on behalfApproved spender (DeFi)
`allowance(owner, spender)`Check approval amountAnyone (view)

简单来说

  1. Universal token language: Every ERC-20 token speaks the same interface — MetaMask, Uniswap, Aave, and Coinbase all work with USDC, UNI, LINK, and 500,000+ other tokens because they all follow the same rules.
  2. Balances in a ledger: The contract keeps a mapping of addresses to balances — `transfer()` subtracts from sender and adds to receiver, all within the contract’s internal ledger.
  3. Approval for DeFi: The `approve()` function lets DeFi protocols spend tokens on your behalf — when you “approve” Uniswap, you’re giving it permission to move your USDC for a swap.
  4. ICO enabler: ERC-20 made token creation trivial — any developer could launch a token in hours, fueling the 2017 ICO boom where thousands of projects raised billions.
  5. The DeFi primitive: Compound, Aave, Uniswap, and every DeFi protocol are built around ERC-20 tokens. Remove ERC-20 and the entire DeFi ecosystem collapses.

实际例子

EventXtra XNUMX大解决方案技术实施成果
USDC稳定币Circle deploys ERC-20 USDC contract; 1:1 USD backing$25B+ in circulation; accepted on every exchange and DeFi protocol instantly
Uniswap 交换User approves USDC, calls swap → Router calls `transferFrom(user, pool)`Seamless swap leveraging ERC-20 approve/transferFrom pattern
Aave贷款User deposits ERC-20 USDC; receives ERC-20 aUSDC representing depositAll lending mechanics built on ERC-20 composability
ICO 融资Project launches ERC-20 token; investors send ETH, receive tokens2017-2018: $20B+ raised via ERC-20 token sales

 优势

企业优势描述
通用兼容性Any ERC-20 token works with any compliant wallet, exchange, or DeFi protocol
简单的实现150 lines of Solidity to deploy a fully functional token
ComposabilityERC-20 tokens nest inside DeFi protocols enabling “money legos”
Ecosystem network effects500,000+ tokens; every tool and interface supports ERC-20
Audited reference implementationsOpenZeppelin’s ERC-20 is battle-tested with billions in value

 缺点与风险

坏处描述
approve() double-spend riskUsers can be front-run when changing allowances; requires two transactions to safely reset
Lost tokens riskERC-20 has no protection against sending tokens to contracts that can’t receive them
Inflationary potentialNo standard supply cap mechanism — projects can mint unlimited tokens if designed poorly
Fee token problemERC-20 transfers require ETH for gas — tokens alone can’t pay their own fees

风险管理提示:

  • 批准之前 DeFi协议, understand what you’re authorizing — unlimited approvals grant perpetual access to spend your tokens
  • Use tools like Revoke.cash to review and revoke old ERC-20 approvals to reduce attack surface
  • Verify token contract addresses from official sources — scammers deploy fake ERC-20 tokens with similar names

 常见问题解答

What is the difference between ETH and ERC-20 tokens?

ETH is Ethereum’s native currency — not an ERC-20 token. ERC-20 tokens are created by smart contracts ON Ethereum. Wrapped ETH (WETH) is an ERC-20 version of ETH that allows it to participate in DeFi protocols that require ERC-20 compliance.

How many ERC-20 tokens exist?

As of 2024, over 500,000 unique ERC-20 token contracts have been deployed on Ethereum mainnet. The vast majority have negligible market value; approximately 1,000-5,000 have meaningful liquidity and use.

What is an unlimited approval in ERC-20?

Calling `approve(dex, type(uint256).max)` grants the DEX permission to spend your entire token balance forever. This is common for convenience but creates risk — if the protocol is hacked, all approved tokens can be stolen.

Can ERC-20 tokens be minted or burned?

The ERC-20 standard itself doesn’t specify minting or burning — it’s optional. Projects implement minting (increasing `totalSupply`) and burning (reducing it) according to their tokenomics design.

Why was ERC-20 revolutionary?

Before ERC-20, every token had a custom interface — exchanges and wallets required custom integration for each token. ERC-20 created a universal language: build once for ERC-20, and you support all tokens instantly.

UPay小贴士: Before interacting with any ERC-20 token DeFi protocol, use Etherscan to look up the token contract address and verify it matches the official project address — scammers create tokens with identical names and symbols to steal approvals from careless users.

免责声明:本内容仅供教育用途,不构成任何财务或投资建议。在做出任何财务决策之前,请务必自行进行研究。

UPay——让加密货币成为百科全书

新闻