On this page
ERC-20 Token Standard: The Rules for Fungible Tokens
The ERC-20 token standard is the common interface that nearly every fungible token on Ethereum follows. It defines a small set of functions a smart contract must expose so that wallets, exchanges, and other contracts can move the token without custom code.
Key Takeaways
- ERC-20 is the interface that lets fungible tokens work identically across Ethereum wallets and applications.
- The standard requires 6 functions and 2 events; name, symbol, and decimals are optional.
- The approve-then-transferFrom pattern is the most common source of user error and approval-drain scams.
- Standardization is what makes tokens tradable on any decentralized exchange without bespoke integration.
Key Takeaways
- ERC-20 is the interface that lets fungible tokens work identically across Ethereum wallets and applications.
- The standard requires 6 functions and 2 events; name, symbol, and decimals are optional.
- The approve-then-transferFrom pattern is the most common source of user error and approval-drain scams.
- Standardization is what makes tokens tradable on any decentralized exchange without bespoke integration.
What It Is
ERC-20 stands for Ethereum Request for Comments, proposal number 20. Fabian Vogelsteller proposed it in November 2015, and it became the template for fungible tokens. Fungible means each unit is identical and interchangeable, the way one dollar bill is the same as any other.
The standard is published formally as EIP-20. It does not dictate what a token represents or how new units are created. It only specifies the function names, inputs, and outputs that a compliant contract must provide, so outside software knows exactly how to talk to it.
The Intuition
Before a shared standard existed, every token contract could name its transfer logic differently. A wallet that wanted to support 50 tokens would need 50 custom integrations. That does not scale.
ERC-20 solves coordination, not technology. By agreeing on one interface, the whole network gains interoperability for free. A new token that follows the rules is immediately usable in any wallet, listed on any decentralized exchange, and composable with any lending protocol. The standard is a contract about vocabulary, and that shared vocabulary is what made the token economy possible.
How the ERC-20 Token Standard Works
A compliant contract must implement 6 functions and emit 2 events. The functions are:
totalSupply() -> total tokens in existence
balanceOf(owner) -> token balance of an address
transfer(to, amount) -> send your own tokens
approve(spender, amount) -> authorize a third party to spend
allowance(owner, spender) -> remaining approved amount
transferFrom(from, to, n) -> spender moves approved tokens
The two events are Transfer, emitted whenever tokens move, and Approval, emitted when an allowance is set. Events matter because wallets and explorers do not constantly poll every contract. Instead they listen for these emitted logs to update balances and show history, so a compliant contract that emits them correctly is what makes your portfolio appear without custom tracking.
Three metadata functions, name(), symbol(), and decimals(), are optional but almost always included. The decimals value tells software how to display balances. Most tokens use 18 decimals, so a balance stored as 1,000,000,000,000,000,000 displays as 1 token. The blockchain only stores whole numbers, so decimals are purely a display convention layered on top of those integers.
The approve-and-transferFrom pair is the part newcomers misread. To let a decentralized exchange swap your tokens, you first call approve to grant it an allowance. The exchange then calls transferFrom to pull the tokens when you trade. This two-step design lets a contract move your tokens on demand without you sending them in advance.
Worked Example
Imagine a token with 18 decimals and you want to swap on a decentralized exchange.
First, you call approve(exchange, 100). This sets the exchange's allowance to 100 tokens. No tokens have moved yet; you have only granted permission.
When you place a trade for 40 tokens, the exchange contract calls transferFrom(you, pool, 40). The contract checks that your allowance is at least 40, moves the tokens, and reduces your remaining allowance to 60. An Approval event recorded the original grant and a Transfer event records the movement.
If you had approved an unlimited amount to save gas on future trades, that allowance stays open until you revoke it. That is convenient, and it is also why a flaw in the spender contract could later drain the full balance. The remaining allowance is readable at any time through allowance(you, exchange), which is how approval-checking tools surface every open permission you have granted so you can revoke the ones you no longer need.
Common Mistakes
-
Approving unlimited spending and forgetting it. Many apps request an infinite allowance for convenience. If that contract is later exploited, the attacker can move every token you hold. Granting only what you need and revoking unused approvals limits the damage.
-
Sending tokens to a contract address by mistake. A plain
transferto a contract that was not built to handle the token can lock those tokens forever, because ERC-20 has no receiver hook to reject them. -
Assuming all ERC-20 tokens behave identically. Some tokens charge a fee on transfer or rebase their supply. These break naive integrations that assume the amount sent equals the amount received.
-
Confusing the token with the network coin. ERC-20 tokens are not the same as ether. You still need ether to pay gas, even when moving a token.
-
Treating decimals as a guarantee. While 18 is common, some tokens use 6 or 8. Hard-coding 18 produces balances that are off by orders of magnitude.
Frequently Asked Questions
What is the ERC-20 token standard in simple terms? The ERC-20 token standard is a shared rulebook that tells fungible tokens on Ethereum which functions to expose. Because every compliant token speaks the same language, any wallet or exchange can support it without custom code.
How does the ERC-20 standard affect investment decisions? Most tradable tokens you can buy on a decentralized exchange are ERC-20, so understanding allowances helps you avoid approval scams. Checking that a token follows the standard cleanly, without odd transfer fees, reduces the risk of surprises when you trade.
What is a real-world example of an ERC-20 token? Many widely traded stablecoins and utility tokens are ERC-20 contracts. When you swap one for another on a decentralized exchange, both sides of the trade are using the same standard interface.
How can investors use ERC-20 approvals safely? Approve only the amount you intend to spend rather than an unlimited allowance, and periodically review and revoke old approvals using a token-approval tool. This caps how much a compromised contract could ever take.
How is ERC-20 different from ERC-721? ERC-20 covers fungible tokens where every unit is identical and divisible. ERC-721 covers non-fungible tokens where each token has a unique ID and cannot be split, which is why it underpins digital collectibles.
Sources
- Ethereum Improvement Proposals. "EIP-20: Token Standard." https://eips.ethereum.org/EIPS/eip-20
- Ethereum.org. "ERC-20 Token Standard." https://ethereum.org/en/developers/docs/standards/tokens/erc-20/
- OpenZeppelin Docs. "ERC-20." https://docs.openzeppelin.com/contracts/5.x/erc20
- Ethereum.org. "Decentralized Finance (DeFi)." https://ethereum.org/en/defi/
Disclaimer
This article is educational content only and is not financial advice. Nothing here is a recommendation to buy, sell, or hold any security. Consult a licensed advisor before making investment decisions.
Back to your knowledge path