Table of contents

  • Introduction

  • What is the ERC-20 standard?

  • Ethereum Token Overview

  • How are ERC-20 tokens created?

  • What features does ERC-20 have?

    • Stablecoins

    • Security Tokens

    • Utility Tokens

  • Can I participate in ERC-20 token mining?

  • Pros and Cons of ERC-20 Tokens

    • Advantages of ERC-20 Tokens

    • Disadvantages of ERC-20 Tokens

  • What are the differences between ERC-20, ERC-1155, ERC-223 and ERC-721?

  • Summarize


Introduction

Ethereum was founded by Vitalik Buterin in 2014 as an open-source platform for launching decentralized applications (DApps). Buterin's motivation for creating this new blockchain was largely due to the lack of flexibility of the Bitcoin protocol.

Since its launch, the Ethereum blockchain has attracted many developers, businesses and entrepreneurs, giving rise to a new industry of user-launched smart contracts and distributed applications.

In this article, we will look at the ERC-20 standard, which is an important framework for creating tokens. Although it is only applied to the Ethereum network, it is the inspiration for other blockchain standards such as Binance Chain's BEP-2.


What is the ERC-20 standard?

In Ethereum, ERC stands for Ethereum Request for Comments. These technical documents outline Ethereum programming standards. Do not confuse them with Ethereum Improvement Proposals (EIPs), which are similar to Bitcoin's BIPs and are suggestions for improvements to the protocol itself. The goal of ERC is to establish a protocol that facilitates interaction between applications and contracts.

Developed and written by Vitalik Buterin and Fabian Vogelsteller in 2015, ERC-20 proposes another relatively simple format for Ethereum-based tokens. As long as developers follow the outline, they do not need to reinvent the wheel and can build directly on the existing foundations of the entire industry.

Once new ERC-20 tokens are created, they will automatically interoperate with services and software that support the ERC-20 standard (software wallets, hardware wallets, exchanges, etc.).

It is important to note that the ERC-20 standard has evolved into EIPs (specifically EIP-20) several years after the original widely circulated proposal, but even after several years, the name "ERC-20" has been retained.


Ethereum Token Overview

Unlike ETH (Ethereum's native cryptocurrency), ERC-20 tokens are not stored in accounts, but exist only inside a contract, like an independent database. It specifies the rules of the token (i.e. name, symbol, divisibility) and keeps a list of Ethereum addresses that map user balances.

To transfer tokens, users must send a transaction to a smart contract, asking the contract to allocate part of the balance somewhere else. For example, if Alice wants to send 5,000 Binance Academy Tokens to Bob, she would call a function in the corresponding smart contract to execute the instruction.


Users interacting with a smart contract


Her call contains what looks like a regular Ethereum transaction that pays 0 ETH to the token contract. This call contains, among other fields in the transaction, Alice's intent - in this case, that she wants to transfer the tokens to Bob.

Even if she doesn't send Ether, she must pay the specified fee to get her transaction included in the block. If she doesn't have ETH, she should deposit some before transferring tokens.

Here’s a real example from Etherscan: Someone calls a BUSD contract. You can see that the tokens have been transferred and the fee has been paid, even though the value field shows 0 ETH was sent.

Next, let’s take a quick look at the typical ERC-20 contract structure.


How are ERC-20 tokens created?


Illustration of an ERC-20 token being created


According to the ERC-20 standard, your contract must set six mandatory functions: totalSupply, balanceOf, transfer, transferFrom, approve, and allowance. In addition, you can also specify optional functions, such as name, symbol, and decimal. You can understand the function function by looking at the name, but don't worry if you don't understand it, we will explain it one by one below.

The following is a function rendered in Ethereum’s Solidity language.


totalSupply

function totalSupply() public view returns (uint256)

When the user calls the above function, the total supply of tokens held by the contract will be returned.


balanceOf 

function balanceOf(address _owner) public view returns (uint256 balance)

Unlike totalSupply, balanceOf uses an address as a parameter. When called, the system returns the balance of tokens held at that address. Remember that accounts in the Ethereum network are public and transparent. As long as you know the address, you can query the balance of any user.


Transfer

function transfer(address _to, uint256 _value) public returns (bool success)

The transfer function supports users to transfer tokens to each other. You need to provide the token receiving address and the transfer amount.

Once called, transfer will trigger an event (in this case, the "transfer" event), which basically tells the blockchain to include a reference to this function.


transferFrom

function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)

The transferFrom function is a convenient alternative to the transfer function, effectively improving programmability in decentralized applications. Similar to the transfer function, it is used to move tokens, but these tokens do not necessarily belong to the user who calls the contract.

In other words, you can authorize another person or contract to transfer funds on your behalf. For example, if you don't want to pay for a subscription service manually on a daily/weekly/monthly basis, you can let a program do the task for you.

This function triggers the same event as transfer.


approve

function approve(address _spender, uint256 _value) public returns (bool success)

Approve is another very useful function from a programming perspective, as it limits the amount of tokens a smart contract can withdraw from a balance. Without it, a running contract could fail (or be exploited) and all funds could be at risk of being stolen.

Let’s take the subscription model as an example again. Let’s say you hold a large amount of Binance Academy tokens and want to set up a recurring weekly payment for your streaming DApp. You are busy reading articles on Binance Academy and don’t want to spend time manually creating transactions every week.

Holding a large BAC token balance that far exceeds the amount needed to pay for a subscription. To prevent the DApp from paying out all of its assets, you can use approve to set a limit. Assuming your subscription costs 1 BAC per week, if the approval limit is 20 tokens, the subscription fee can be automatically paid for in 5 months.

If something goes wrong and the DApp tries to withdraw all your funds, you will only lose 20 tokens at most. While losing your tokens is frustrating, it is much better than losing all your assets.

After calling this function, approve will trigger the approval event, which, like the transfer function, will write the data to the blockchain.


allowance

function allowance(address _owner, address _spender) public view returns (uint256 remaining)

allowance can be used in conjunction with approve. If token management permissions are granted to a contract, you can use it to check the withdrawable balance of tokens. For example, if a subscription service uses 12 of the 20 approved tokens, calling the allowance function will return a total of 8 tokens.


Other optional functions

All functions discussed above are mandatory. On the other hand, name, symbol, and decimal are optional functions that make ERC-20 more complete. These functions support adding a human-readable name, setting the symbol (i.e. ETH, BTC, BNB), and specifying the number of decimal places a token can be divided into, respectively. For example, a token used as currency would benefit more from being more divisible than a token used to represent property ownership.


See this example on GitHub to see what these elements look like in a real contract.


What features does ERC-20 have?


Illustration of various uses of ERC-20 tokens


Putting all the above functions together, we get an ERC-20 contract. We can query the total supply, check the balance, transfer funds, and authorize other DApps to manage tokens on our behalf.

The flexibility of ERC-20 tokens is a huge advantage. The established protocol does not restrict development, and each party can introduce additional features and set specific parameters based on their needs.


Stablecoins

Stablecoins (tokens pegged to fiat currencies) usually use the ERC-20 token standard. The BUSD contract transaction mentioned above is a typical example, and most stablecoins also use this form.

For stablecoins backed by mainstream fiat currencies, the issuer can hold reserves such as euros, dollars, etc., and then issue tokens for each unit in the reserve. This means that if $10,000 is deposited into the vault, the issuer can create 10,000 tokens, each of which can be exchanged for $1.

From a technical perspective, this is easy to implement in Ethereum. The issuer only needs to launch a contract with 10,000 tokens and then distribute the tokens to users, promising that they can redeem the tokens for a certain proportion of legal currency in the future.

Users can use their tokens to perform a variety of actions, including purchasing goods and services and using them in DApps. In addition, they can also ask the issuer to redeem these tokens immediately. In this case, the issuer can also destroy the returned tokens (making them invalid) and withdraw the equivalent amount of fiat currency from the reserve.

As mentioned above, the contracts governing the system are relatively simple. However, launching a stablecoin requires a lot of attention to many other external factors (e.g. logistics, compliance, etc.), which requires a lot of effort.


Security Tokens

Security tokens are similar to stablecoins and can even be identical at the contract level, as they work in the same way. The difference lies in the issuer: Security tokens represent securities, such as stocks, bonds, or physical assets. They usually (although not always) grant holders a stake in a company or commodity.


Utility Tokens

Utility tokens are probably the most common type of tokens available today. Unlike the previous two types of tokens, utility tokens are not backed by any real asset. If shares in an airline were represented by asset-backed tokens, utility tokens would be like frequent flyer programs: they have some functionality but no external value. Utility tokens can serve many purposes, such as being used as in-game currency, fuel for decentralized applications, and loyalty points.


➠ Want to start your cryptocurrency journey? Buy Ethereum on Binance!


Can I participate in ERC-20 token mining?

You can participate in Ether (ETH) mining, but tokens cannot be mined - we call the creation of new tokens minting. After the contract goes live, the developers will allocate the supply according to the plan and roadmap,

This is usually done through an Initial Coin Offering (ICO), Initial Exchange Offering (IEO), or Security Token Offering (STO). You may come across many variations of these acronyms, but the concepts are very similar. Investors send Ether to a contract address and receive new tokens in return. The funds raised are used to fund future development of the project. Users expect to be able to use their tokens (immediately or later) or resell them for a profit as the project develops.

Token distribution is not necessarily automatic. Many crowdfunding campaigns allow users to pay using various cryptocurrencies such as BNB, BTC, ETH, and USDT, and then distribute the corresponding balance to the address provided by the user.


Pros and Cons of ERC-20 Tokens

Advantages of ERC-20 Tokens

Interchangeability

ERC-20 tokens are fungible, meaning all units are interchangeable. With Binance Academy Tokens, it doesn't matter which specific token you hold. You can trade them with other people, and they function the same way, similar to cash or gold.

This is ideal if you want your token to be a currency. Tokens with distinct characteristics will lose interchangeability and not meet your requirements. This will cause some tokens to be worth less or more than similar tokens, defeating the purpose.


flexible

As discussed in the previous section, ERC-20 tokens are highly customizable and can be tailored to different applications, such as in-game currency, loyalty points for programs, digital collectibles, or even representing art and property ownership.


ERC-20 is gaining popularity in the cryptocurrency space, and the blueprint for building on it is very convincing. Many exchanges, wallets, and smart contracts are now compatible with various newly launched tokens. In addition, developer support and documentation are also quite comprehensive.


Disadvantages of ERC-20 Tokens

Poor scalability

This is a common problem for many cryptocurrency networks, and Ethereum is no exception. In its current form, it does not scale well. Sending transactions during peak times incurs high fees and long delays. Its usability will also be affected if the network is congested due to the use of ERC-20 tokens.

This is not a problem unique to Ethereum, but a trade-off that all secure distributed systems must make. The community plans to address these issues after migrating to Ethereum 2.0, implementing upgrades such as Ethereum Plasma and Ethereum Casper.

Please read "Blockchain Scalability: Sidechains and Payment Channels" to learn more about scalability issues.


Fraud

While there is nothing wrong with the technology itself, the ease with which tokens can be issued can be a disadvantage in some ways. The ease with which simple ERC-20 tokens can be created means that anyone can do it, with both good and bad intentions.

Therefore, you must be careful when investing. Many pyramid schemes and Ponzi schemes are disguised as blockchain projects, so you must do your own research before investing to confirm whether the investment opportunity is legitimate.

 

What are the differences between ERC-20, ERC-1155, ERC-223 and ERC-721?

ERC-20 is the first (and by far the most popular) Ethereum token standard, but it’s not the only one. Over the years, many other standards have emerged. Most of them are improvements on ERC-20, while others try to achieve completely different goals.

A few less common standards apply to non-fungible tokens (NFTs). In some cases, you can be a beneficiary of unique tokens with different properties. If you need to tokenize one-of-a-kind artwork, in-game assets, etc., one of these types of contracts may be more attractive.

For example, the ERC-721 standard is used in the very popular CryptoKitties DApp. This contract provides an API for users to mint their own non-fungible tokens and encode metadata (images, descriptions, etc.).

The ERC-1155 standard can be seen as an improvement over ERC-721 and ERC-20. It supports both fungible and non-fungible token standards in a single contract.

Other options, such as ERC-223 or ERC-621, are designed to improve usability. The former implements protections to prevent accidental transfers of tokens. The latter provides additional functionality for increasing and decreasing the token supply.

To learn more about NFTs, read our Guide to Crypto Collectibles and Non-Fungible Tokens (NFTs).


Summarize

For many years, the ERC-20 standard has been the dominant force in the cryptoasset space. The reasons are obvious: the standard is relatively simple, and anyone can deploy simple contracts to suit a variety of needs (utility tokens, stablecoins, etc.). That said, ERC-20 does lack some features of other standards, and it remains to be seen whether other contract types can take its place.