Introduction to ERC-20 Token Standard

Published by Mario Oettler on

ERC stands for Ethereum Request for Comments. The ERC-20 standard defines a standardized structure of a smart contract that holds fungible tokens. It defines function names, parameters, variables, and events that should be available in an ERC20 based smart contract.

The motivation behind this is that users who want to interact with a smart contract, need to know the ABI. The ABI is necessary to build the user interface and create transactions correctly to communicate with a smart contract. But in most cases the ABI, this is not known to the user. This makes it hard to generate a user interface for a new contract.

For that reason, the ERC20 standard was established. If a contract follows a standard like the ERC20, platforms know how the user interface should look like (because it is a standard). They know the functions, events, variables, etc. to create a user interface and build transactions.

The ERC20 standard was one of the earliest standards. Until now, many other contracts standards such as ERC721 or ERC1155 evolved. They allow different tokens like NFT or are token agnostic. Other standards try to improve flaws and weaknesses of the ERC20 standard by building on it and being compatible with it.

Here, we focus on the ERC20 standard because it is a relatively simple standard that allows us quickly to grasp its functionality.

You can find the definition of the ERC20 here: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md

There also exist some public implementations.

If you compare both implementations you will notice that the Openzeppelin version has additional functions like increaseAllowance(), decreaseAllowance(), mint(), _burn(), _burnFrom().

Besides, the solidity version is 0.4.X which is outdated. That’s why some parts in the code look different from what you find in up-to-date code. One example is the constructor.

Categories:

if()