1. Home
  2. Docs
  3. Docs
  4. What is the ERC-20 token standard?

What is the ERC-20 token standard?

The ERC-20 standard is a specification on the Ethereum blockchain for creating and managing tokens. It allows tokens to be traded, integrated into smart contracts, and used in various wallets and applications on the Ethereum network. It standardizes the functionality and interoperability of tokens.

Example functionalities ERC-20 provides:

transfer tokens from one account to another
get the current token balance of an account
get the total supply of the token available on the network
approve whether an amount of token from an account can be spent by a third-party account

Here are the main methods defined by the ERC-20 standard.

If a Smart Contract implements the following methods and events, it can be called an ERC-20 Token Contract and, once deployed, it will be responsible for keeping track of the created tokens on Ethereum:
function name() public view returns (string)
function symbol() public view returns (string)
function decimals() public view returns (uint8)
function totalSupply() public view returns (uint256)
function balanceOf(address _owner) public view returns (uint256 balance)
function transfer(address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function approve(address _spender, uint256 _value) public returns (bool success)
function allowance(address _owner, address _spender) public view returns (uint256 remaining)
event Transfer(address indexed _from, address indexed _to, uint256 _value)
event Approval(address indexed _owner, address indexed _spender, uint256 _value)
  1. name(): This function returns the name of the token. It’s a public view function, meaning anyone can read the name of the token without performing any transactions.
  2. symbol(): This function returns the symbol or ticker of the token (e.g., “ETH” for Ethereum). It’s also a public view function.
  3. decimals(): This function returns the number of decimal places used by the token. For example, if the token has 18 decimal places, it means that 1 token is represented as 1 followed by 18 zeros. This is crucial for handling fractional tokens.
  4. totalSupply(): This function returns the total supply of the token in circulation. It’s usually a large integer representing the total number of tokens.
  5. balanceOf(address _owner): This function allows you to query the balance of tokens owned by a specific address (_owner). It returns the token balance of the given address.
  6. transfer(address _to, uint256 _value): This function is used to transfer a specified amount (_value) of tokens from the sender’s address to the target address (_to). It returns a boolean value indicating whether the transfer was successful.
  7. transferFrom(address _from, address _to, uint256 _value): This function is used to transfer tokens from one address (_from) to another (_to). However, it typically requires prior approval through the approve function. It returns a boolean value indicating whether the transfer was successful.
  8. approve(address _spender, uint256 _value): This function allows the owner of the tokens to authorize another address (_spender), such as a smart contract, to spend a specific amount (_value) of tokens on their behalf. It returns a boolean value indicating whether the approval was successful.
  9. allowance(address _owner, address _spender): This function is used to check the amount of tokens that an address (_owner) has approved another address (_spender) to spend on their behalf. It returns the remaining approved token amount.
Additionally, there are two events:
    1. Transfer: This event is emitted whenever tokens are transferred from one address to another. It provides information about the sender, receiver, and the number of tokens transferred.
    2. Approval: This event is emitted when an approval for spending tokens is granted. It includes information about the owner, the spender, and the approved token amount.
These functions and events collectively define the ERC-20 token standard, enabling the creation and management of tokens on the Ethereum blockchain.
Tags