What is ERC-20?

Among the blockchain mainnets, the platforms that support smart contracts can issue tokens. For example, you can register by writing a program (smart contract) that issues tokens in Ethereum. In Ethereum, anyone can write and distribute smart contracts, so anyone can issue tokens.

Numerous tokens exist on Ethereum. In addition to stable coins, tokens of various purposes and types are issued, such as utility, security, and community operation. You can use your own form when issuing tokens, but in this case, compatibility problems may occur in exchange with other tokens or linkage with wallets, so a common (standard) form is required when issuing tokens.

Need for ERC-20

ERC stands for Ethereum Request for Comments, and ERC-20 means for the 20th proposal request within Ethereum. The content of the 20th proposal request is to define the format of the interface for external access when issuing tokens. ERC-20 remains one of the most utilized standard interfaces to this day.

In the case of Ether (the coin of Ethereum), there is an account with the generated private key in your wallet and the coin is stored in the account on the blockchain. However, in the case of ERC-20 tokens, there is the smart contract that issued the tokens that exists on the blockchain. The smart contract expresses in a way that indicates how many tokens are assigned by the contract to your account. Therefore, it can be said that the real asset is owned by the token contract while you have control over moving your portion of the assets in the contract. Since the integrity of the token contract is guaranteed on the blockchain, the smart contract can be said as a form of ledger that manages the token.

For example, let's say Alice sends 10 ABC tokens to Bob in the ABC token contract. Alice will submit a transaction signed with her private key to the blockchain. In the token contract, if Alice has 10 ABC, she executes the action of transferring 10 ABC tokens to Bob. Let's say that the name of the function that works like this is marked as “transfer” on this ABC token contract. However, there are not only ABC tokens, but DEF tokens and GHI tokens as well. For the exact same transfer function, if each of these different contracts use different function names such as “send” or “transmit”, it will be difficult to exchange tokens with each other and it may be very difficult to implement in the wallet. Therefore, ERC-20 is proposed as a standard interface to avoid this kind of situation.

Contents of the ERC-20

ERC-20 has the following functions defined. (It’s okay to not know how to code, however, focus your attention on the function name.)

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)

Let's take a simple example of using the functions of the ERC-20 token with USDT, which is famous as a stablecoin. The name of the USDT token is ‘Tether USD’ and the symbol is ‘USDT’. If you want to define a name and symbol when issuing tokens on the blockchain, you can define it in the name() and symbol() functions of ERC-20. In addition, decimals are used to indicate how much the unit of money will be in consideration of the token issuance and circulation volume.

In addition, each function is used in the following cases: Think of the token contract as a single ledger, think about how you can request and retrieve the contents of the ledger, and think about the name of the following function.

  • totalSupply is the interface to identify how many tokens will be issued in total.

  • balanceOf returns how much balance is remaining in the account.

  • transfer is for transferring tokens to another person (or address).

  • approve is for granting another person (or address) with the authority (permission) to withdraw a certain allowed amount.

  • allowance returns the remaining number of tokens that the spender will be allowed to spend on behalf of owner.

  • transferFrom is used when someone with an approved permission sends a token on your behalf. For example, permissioned person A transfers your balance to a person B, however, this must be approved in advance.

In addition, there are two other functions for Events, which notify when the function described above is executed. The reason for the relatively small number of events is that there are only two cases when an asset moves or indicates the possibility of a move. Circumstances such as what the name is or whether someone has looked it up are not specific to an asset's change, so no events are raised. For example, when transfer(function) is executed to cause an asset to move, a Transfer(event) for this history is triggered.

event Transfer(address indexed _from, address indexed _to, uint256 _value)
event Approval(address indexed _owner, address indexed _spender, uint256 _value)

Knowing this, you can see that the name, symbol, currency unit or balance of the token displayed in your wallet is information obtained from the ERC-20 token contract. Also, when transferring tokens to other people, you can see that functions such as transfer, approve, and allowance are used in the token contract. By having an ERC-20 standard that is applied equally to all tokens, it is very convenient because tokens can be easily added during development.

ERC-20 represents a standard interface corresponding to Ethereum, but there is a standard used for issuing tokens specific to each blockchain network. Unless you're a developer, it doesn't matter if you don't know what ERC-20 is. However, one of the many mistakes users make is that they send their ERC-20 tokens to an address on a non-Ethereum network. In order to prevent this costly mistake, it is essential to have the knowledge to distinguish whether it is an ERC-20 token or a token issued in the standard specification of another network. For more information on this, please refer to the following link.

Understanding the blockchain network

Last updated