Academy

Intro ERC-20 Tokens

Fungible Token Standard

Intro ERC-20 Tokens

Fungible Token Standard

Previously, we explored the concept of smart contracts and how they can be used to execute predefined rules on a blockchain. One of the most impactful use cases of smart contracts is the implementation of token standards. The ERC-20 standard was introduced to create a universal and interoperable framework for tokens on the EVM.

The ERC-20 standard defines a set of functions and events that a token contract must implement, making it easier for wallets, exchanges, and applications to interact with these tokens. As a result, ERC-20 tokens have become the foundation for countless decentralized finance (DeFi) protocols, governance systems, and utility applications.

To better understand why ERC-20 is such a critical part of EVM’s ecosystem, let's first explore the concept of fungibility.


Fungibility

Fungibility refers to an asset’s ability to be exchanged for another of the same type without any difference in value. Let’s use currency as an example:

  • A 10billisconsideredfungiblebecauseitholdsthesamevalueasanother10 bill is considered fungible because it holds the same value as another 10 bill. If you exchange one $10 bill for another, their value remains the same.
  • Similarly, you can break a 10billintosmallerdenominationsliketwo10 bill into smaller denominations like two 5 bills or ten $1 bills, without changing the total value.

ERC-20 tokens are fungible by design. For instance:

  • 1 unit of an ERC-20 token (e.g., USDC or USDT) is indistinguishable and interchangeable with any other unit of the same token.
  • The fungibility of ERC-20 tokens makes them ideal for use cases such as stablecoins, governance tokens, and liquidity pool assets.

However, fungibility also introduces a limitation: if a use case requires unique attributes for individual tokens, the ERC-20 standard is insufficient. For such scenarios, the ERC-721 standard is used instead, as we will discusse in next chapter.


ERC-20: The Standard

The ERC-20 token standard was designed to simplify the implementation of fungible tokens and ensure compatibility across various EVM-based applications. At its core, an ERC-20 token contract allows the following operations:

  • Tracking balances of token holders.
  • Transferring tokens between accounts.
  • Approving other accounts to spend tokens on behalf of the owner.
  • Querying details about the token, such as its name, symbol, and total supply.

Below is the interface for ERC-20 tokens as defined in the original proposal:

interface ERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);
    
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
Edit on GitHub

Last updated on

On this page