Content

  • Introduction

  • What is the ERC-20 standard?

  • A Brief Overview of Ethereum Tokens

  • How are ERC-20 tokens created?

  • What are the functions of ERC-20 tokens?

    • Stablecoins

    • Security tokens

    • Utility tokens

  • Is it possible to mine ERC-20 tokens?

  • Advantages and disadvantages of ERC-20 tokens

    • Benefits of ERC-20 tokens

    • Disadvantages of ERC-20 tokens

  • ERC-20, ERC-1155, ERC-223, ERC-721 - what's the difference?

  • Summary


Introduction

Ethereum was founded in 2014 by Vitalik Buterin and was intended to be an open-source platform for running decentralized applications (DApps). When creating a new blockchain, Buterin took into account the problem of insufficient flexibility of the Bitcoin protocol.

Since its launch, the Ethereum blockchain has attracted many developers, companies, and entrepreneurs, and has ushered in a growing industry of users running smart contracts and distributed applications.

In this article we will look at the ERC-20 standard - the basis for creating tokens. The standard was developed specifically for the Ethereum network, but managed to inspire other blockchain standards, for example, BEP-2 Binance Chain.


What is the ERC-20 standard?

ERC in Ethereum is a request for proposals to improve the network (English: Ethereum Request for Comments). ERCs are technical documents that outline programming standards on Ethereum. These should not be confused with Ethereum Improvement Proposals (EIPs), which, like Bitcoin's BIPs, propose improvements to the protocol itself. The purpose of the ERC is to establish agreements that make it easier for applications and contracts to interact with each other.

ERC-20 was created in 2015 by Vitalik Buterin and Fabian Vogelsteller with the goal of offering a relatively simple format for creating tokens on Ethereum. By relying on an existing standard, developers save time and effort. With ERC-20, they can create new tokens without worrying about compatibility and security.

The new ERC-20 tokens will be compatible with all services and software that support this standard (software wallets, hardware wallets, exchanges, etc.).

It should be noted that EIP (namely EIP-20) was developed based on the ERC-20 standard. This happened several years after the launch due to the widespread use of the standard. But even years later, the name “ERC-20” is still relevant.


A Brief Overview of Ethereum Tokens

Unlike ETH (Ethereum's native cryptocurrency), ERC-20 tokens are not stored in accounts. They exist only within the contract, which is a kind of autonomous database. The contract defines the terms for the tokens (eg name, symbol, divisibility). It also contains a list that matches users' balances with their Ethereum addresses.

To move tokens, users must submit a transaction to the contract requesting that a portion of their balance be moved to another location. For example, if Alice wants to send Bob 5,000 BinanceAcademy tokens, she runs a function inside the smart contract asking him to do so.


Пользователи, взаимодействующие со смарт-контрактом


Her request is placed inside a seemingly normal Ethereum transaction, which charges 0 ETH to the smart contract. The request is added to an additional field in the transaction, which specifies what exactly Alice wants to do -  in our case, transfer the tokens to Bob.

Even though she doesn't send Ether, she still has to pay a fee, denominated in Ether, to have her transaction added to the block. If she does not have ETH, she will need to purchase it before making the transaction.

Here is a real-life example of such a process on Etherscan: someone makes a request for a contract in BUSD. We see that the tokens were transferred and the fee was paid, despite the fact that its amount is 0 ETH.

We can now dive deeper into the structure of the ERC-20 contract.


How are ERC-20 tokens created?


Иллюстрация создания токена ERC-20


To be compatible with ERC-20, your contract must include six required functions: totalSupply, balanceOf, transfer, transferFrom, approve and allowance. Additionally, you can add additional functions such as name, symbol and decimal. From the names of the functions you can understand their purpose. Next we will look at each of them in more detail.

Below the functions are presented as they are written in the Solidity language created for Ethereum.


totalSupply

function totalSupply() public view returns (uint256)

When prompted by the user, the above function shows the total number of tokens in the contract.


balanceOf 

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

Unlike totalSupply, the balanceOf function uses a parameter (address). It shows the balance of address tokens upon request. Remember that Ethereum accounts are public, so you can query the balance of any user as long as you know their address.


translation

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

The transfer function transfers tokens from one user to another. To use it, you need to specify the recipient's address and the transfer amount.

The transfer function fires an event (in our case, event transfer), which tells the blockchain to include a reference to it.


transferFrom

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

The transferFrom function is a more convenient alternative to the transfer function, which provides greater programmability in decentralized applications. Like transfer, it is used to move tokens, but they do not necessarily belong to the person accessing the contract.

In other words, you can authorize another person or another contract to transfer funds on your behalf. Another use case involves automatic payment for subscription-based services in case you don't want to manually send payments every day/week/month. The program will do this for you.

This function fires the same event as transfer.


approve

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

Approve is another useful function from a programmability point of view. With its help, you can limit the number of tokens that a smart contract can withdraw from your balance. In its absence, there is a risk of the contract being misused: someone could exploit it for their own purposes or steal all your funds.

Let's look at an example with a subscription model. Let's say you have a lot of BinanceAcademyTokens and want to set up weekly payments for your DApp streaming service. You're already studying Binance Academy content day and night, and you don't want to spend time manually creating a transaction every week.

Let's say you have a large supply of BinanceAcademyTokens, far exceeding your subscription fee. To prevent the DApp service from draining it, you can set a limit using the approve function. For example, your subscription costs one BinanceAcademyToken per week. If you limit the maximum amount to twenty tokens, then the subscription can be paid automatically over five months.

In the worst case scenario, if the DApp tries to withdraw all your funds or an unexpected error occurs, you will only lose twenty tokens. This option does not eliminate possible problems, but it protects you from losing all your assets.

When the approve function is called, the approval event is fired. Like the transfer event, it writes data to the blockchain.


allowance 

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

The allowance function can be used in conjunction with the approve function. Once you have given the contract permission to manage its tokens, you can use this feature to check how many tokens it can still write off. For example, if your subscription has used twelve of the twenty allowed tokens, then when you call the allowance function, the number eight should be displayed.


Additional functions

The features we discussed above are mandatory. The name, symbol, and decimal functions are optional, but can improve your ERC-20 contract. They give you the ability to add a clear name, set a symbol (eg ETH, BTC, BNB) and specify how many decimal places the tokens can be divided into. For example, tokens that are used as currency may benefit more from greater divisibility than a token that represents ownership.


You can see these elements in a real contract in this example on GitHub.


What are the functions of ERC-20 tokens?


Иллюстрация различных вариантов использования токенов ERC-20


If we combine all the above features, we get an ERC-20 contract. It can be used to query the total supply of tokens, check balances, transfer funds, and grant permissions to other DApps to manage tokens.

The main advantage of ERC-20 tokens is flexibility. Using them, you can also implement additional features and set certain parameters according to your needs.


Stablecoins

Stablecoins (tokens pegged to fiat currencies) often use the ERC-20 token standard. One example is the BUSD contract transaction we referenced earlier. Most stablecoins are available in this format.

The issuer of a fiat-backed stablecoin holds reserves in euros, dollars, etc. They then create a token for each unit in their reserve. This means that if $10,000 were in the vault, the issuer could create 10,000 tokens, each worth $1.

This is quite easy to implement in Ethereum. The issuer launches a contract with 10,000 tokens. They will then be distributed to users with the prospect of further redemption in fiat currency.

Users can use tokens to pay for goods and services or use them in DApp applications. In addition, users have the option to request an immediate exchange of tokens from the issuer. In this case, the issuer burns the returned tokens (they become unavailable) and withdraws the equivalent amount in fiat from its reserves.

The contract governing this process, as we have already said, is relatively simple. However, launching a stablecoin involves many external factors such as logistics, legal and regulatory compliance, etc.


Security tokens

Security tokens are similar to stablecoins. At the contract level, they can be considered identical because they work the same way. But there is a significant difference for the issuer. Security tokens represent securities (stocks, bonds or physical assets). They often (though not always) give the holder some interest in a business or product.


Utility tokens

Utility tokens are by far the most common types of tokens. Unlike the two previous options, they are not supported by anything. If asset-backed tokens are like airline shares, utility tokens are more like a frequent flyer loyalty program: they serve a purpose but provide no other value. Utility tokens can have a huge variety of uses. So, they can act as in-game currency, fuel for decentralized applications, loyalty points and much more.


➠ Ready to get started with cryptocurrency? Buy Ether on Binance!


Is it possible to mine ERC-20 tokens?

Users can mine ether (ETH), but not tokens - tokens are created. When the contract is launched, developers distribute tokens in accordance with existing plans and roadmap.

This is typically done through an initial coin offering (ICO), an initial exchange offering (IEO), or a security token offering (STO). You may come across different abbreviations, but in essence they are all pretty close. Investors send Ether to the contract address and receive new tokens in return. The funds received are used to finance the further development of the project. Users expect to be able to use their tokens (immediately or later) or resell them for profit as the project develops.

The token distribution process does not need automation. Many crowdfunding events allow you to pay in a variety of digital currencies (such as BNB, BTC, ETH, and USDT). Then, in accordance with the amount paid, user balances at the specified addresses are replenished.


Advantages and disadvantages of ERC-20 tokens

Benefits of ERC-20 tokens

Interchangeability

Fiat currencies are fungible because each unit is indistinguishable from another equivalent unit. If you have the BinanceAcademyToken, then it doesn't matter which specific token you own. Such tokens can be sold to other users and they will remain functionally identical, like money or gold.

This is very convenient if you want to use the token as a currency. In this case, you do not need individual units with distinctive features that make them non-interchangeable. Differences may cause some tokens to become more (or less) valuable than others, which in turn will disrupt their primary function.


Floating rate

As we established in the previous section, ERC-20 tokens are highly customizable and can be adapted for a wide variety of uses. So, for example, they can be used as in-game currency, in loyalty programs, as digital collectibles, or even as fine art and property rights.


The popularity of ERC-20 in the cryptocurrency industry leads to the use of this protocol as the basis for the creation of new tokens. This is why there are many exchanges, wallets and smart contracts already compatible with newly released tokens. Moreover, they are provided with extensive developer support and have all the necessary documentation.


Disadvantages of ERC-20 tokens

Scalability

Like many cryptocurrency networks, Ethereum is not immune to problems that arise as the network grows. The network is currently experiencing scalability issues, so attempting to send a transaction during busy hours results in high fees and delays. If you launch an ERC-20 token when the network is congested, the usability of the token may be affected.

It's not just Ethereum that faces this problem. Distributed systems have to make trade-offs to achieve security. The community plans to solve this problem when moving to Ethereum 2.0, which will implement the Ethereum Plasma and Ethereum Casper updates.

Learn more about scalability issues in our article Blockchain Scalability – Sidechains and Payment Channels.


Fraud

Although this is not a problem with the technology itself, the ease of launching a token can be considered a disadvantage. Creating a simple ERC-20 token requires minimal effort, which means anyone can do it, including for criminal purposes.

Thus, you need to be very careful about what you invest in. There are a number of Ponzi and pyramid schemes disguised as blockchain projects. Before investing, study everything carefully to decide for yourself whether the project is reliable.

 

ERC-20, ERC-1155, ERC-223, ERC-721 - What's the difference?

ERC-20 was the first (and still remains the most popular) Ethereum token standard, but it is far from the only one. Over the years, many other protocols have emerged that offer improvements to ERC-20 or attempt to achieve other goals.

Some of the less common standards are used to create non-fungible tokens (NFTs). Depending on the purpose of use, you may need unique tokens with different attributes. If you want to tokenize a unique piece of art, a gaming asset, etc., you can use one of these contract types.

For example, the ERC-721 standard was used for the extremely popular DApp CryptoKitties. Such a contract provides users with an API to create their own non-fungible tokens and encode metadata (images, descriptions, etc.).

The ERC-1155 standard can be considered an improvement on ERC-721 as well as ERC-20. This standard supports both fungible and non-fungible tokens in a single contract.

Other options, such as ERC-223 or ERC-621, aim to improve usability. ERC-223 implements precautions to prevent accidental transfer of tokens. ERC-621 offers additional features for increasing and decreasing the supply of tokens.

To learn more about NFTs, be sure to check out the Guide to Crypto Collectibles and Non-Fungible Tokens (NFTs).


Summary

The ERC-20 standard has dominated the crypto asset space for many years, and it's no surprise. Anyone can easily deploy a simple contract for various purposes (utility tokens, stablecoins, etc.). However, ERC-20 lacks some features that are present in other standards. And while there is no exact answer to the question whether other types of contracts will supplant it in the future or not.