ERC (Ethereum Request for Comment) token standards are built upon and utilise the Ethereum blockchain. Most of us have only heard about the vastly used ERC-20, while becoming more familiar with the ERC-721 and ERC-1155 token standards thanks to the growing adoption of NFTs (Non-Fungible Tokens) by upcoming projects. This article gives an overview of what are ERC tokens, their various types, and functions.
- ERC tokens are special forms of smart contracts that utilise the Ethereum blockchain, rather than having their own blockchain like Bitcoin.
- They can have different functions and even a combination of features.
- ERC tokens can be Fungible, Non-fungible, and Semi-fungible.
What is a token and how do we classify them?
First of all, ‘tokens‘ are programmable digital units of value that are recorded on a distributed ledger protocol such as a blockchain. Basically, ERC20 tokens are special forms of smart contracts that utilize Ethereum’s blockchain. They can also be described as digital assets which are not the main currency of that blockchain. While $ETH and $BTC both have their blockchain and are thus far considered as coins, tokens don’t.
There are different types of tokens. Utility tokens differ from the rest because they usually offer a wider functionality than, for example, a means of payment (coins, like $BTC) or voting power on a platform (such as governance tokens, like $UNI). They can combine multiple purposes, are integrated into an existing protocol and used to access its services. They also provide network activity, which ensures strength of the platform’s economy.
To easily understand how they fit into the blockchain ecosystem, we need to understand how Ethereum works first: we can think of it as an operating system on top of which applications (smart contracts) can be built (written), just like developers build applications for Android and iOS. One difference being that applications on Ethereum can be decentralized (Dapps). Once we have these platforms, we can (if we want) create tokens, each time choosing the most appropriate standard for our purpose.
Years ago, when there was no standard in use, it was far more complicated for developers to make smart contracts interact with each other; they had to create specific implementation standards to develop a token and launch it on Ethereum’s network. Then, the ERC-20 came out and that heavily simplified the process.
Another distinction is between Fungible and Non Fungible tokens.
In this case, each token is equivalent to all the others and they are interchangeable (1 $BTC will always be equal to any other 1 $BTC).
First proposed in 2015, it’s the industry standard and most accepted one. It makes the initial distribution of tokens extremely easy, so it became massively used in the 2017 ICOs craze. The ERC-20 contracts are composed of 6 mandatory functions and 3 optional ones.
6 mandatory functions:
- balanceOf(): keeps track of the balance in each user wallet
- totalSupply(): shows the current total supply in circulation
- transfer (): lets the owner send a specific amount to another address
- transferFrom(): allows a smart contract to automate the transfer process and send a given amount of the token on behalf of the owner
- approve(): approves the withdrawal of tokens from the owner’s address to the receiving address. It also guarantees that nobody could create more tokens out of nothing, keeping the supply under control
- allowance(): makes sure that the owner has at least as many tokens as the amount set in the approve function; the transactions added to the blockchain have been proved valid
3 optional functions:
- name(): pretty self explanatory!
- symbol(): 3-4 letter abbreviation
- decimals(): it is impossible to write decimal places in Solidity- only whole numbers, so this function is needed. Most tokens use 18 decimals
How to send ERC-20 tokens?
There are two ways of sending ERC-20 tokens, depending on if you want to send them directly or delegate the function to a smart contract. You can either:
- call the transfer() function to send tokens to another wallet address
- call the approve() function and then transferfrom() from the receiver contract
Besides the ease of use and the popularity that this standard immediately gained among the community, its main flaw soon became obvious, causing millions of dollars worth of tokens to be lost forever in smart contracts.
Limitations of ERC-20 tokens and what are wrapped tokens?
What happens if you simply use the transfer() function to send tokens to a smart contract which is not made to receive them?
The transaction will succeed and these tokens will be credited to the receiver address, but they won’t be recognized by the recipient and they will remain there forever, unusable.
Another limitation is that since $ETH itself was obviously created before the ERC-20 standard was even developed, it is not compliant with it (nor with other standards). That is why to interact with many contracts, we need to “wrap” $ETH into $WETH (wrapped ether, which IS an ERC-20 token, pegged to $ETH 1:1).
To solve the various flaws, new standards were proposed. The most famous ones are the following.
- prevents funds to be lost
- half as expensive
- backwards compatible
This standard was proposed by a Reddit user known as “Dexaran”; it focuses on security and tries to fix the main flaw of its predecessor, by using a unique, new transfer() function, which allows tokens to be sent to either a personal address or a smart contract. Moreover, it includes a tokenFallback() function that checks the receiving contract for the same function.
Basically, if the receiver is a regular address (not a contract), the transfer will be similar to the ERC-20 one, while if the receiver is a contract, the tokenFallback() function will be triggered. If the receiving contract does not have this function, the transaction will fail but all the funds will be returned to the sender address.
Simplifying the transfer and reducing it to just one single step, the process will also be cheaper (less gas fees!). The ERC-223 standard is backwards compatible with the ERC-20, as it keeps all of the original functionalities and solves the biggest issues. The ChainLink ($LINK) token has been described by its developers as “an ERC20 token, with the additional ERC223 ‘transfer and call’ functionality of transfer, allowing tokens to be received and processed by contracts within a single transaction”.
The ERC-223 standard has never been finalized.
- makes transactions smoother
- allows for approved operators
- standard for minting/burning tokens
- backwards compatible with ERC-20
This standard was developed by Jacques Dafflon and Jordi Baylina, it is similar to ERC-20 and it relies upon the ERC-1820. Before that, developers couldn’t identify the functions which can be implemented by smart contracts. By creating a central registry of contracts on the network, the ERC-777 can use it to identify the interfaces a smart contract uses.
Its uniqueness is the friction reduction in transactions. It also defines a new set of functions, for example it uses send() instead of transfer(), authoriseOperator() instead of approve(), tokenReceived() handler function instead of tokenFallback().
It also allows for more customization, a list of approved operators so that people can approve smart contracts to move tokens on their behalf, and creates a standard for minting and burning tokens (very useful for particular projects).
A pure ERC-777 is not compatible with ERC-20 but the standard described how to make it compatible.
The ERC-777 standard became finalized on May 6th, 2019.
Other fungible tokens
There have been many other proposals combining some aspects of different standards into each other.
- ERC-827 combines some of the advantages of ERC-223 and ERC-20 standards, it enables token transfer for a 3rd party to spend it
- ERC-664 is mainly centered on modularity and makes it possible to update token contracts
- ERC-677 provides a safe way for new contracts to transfer tokens to external contracts
- ERC-621 can increase or decrease the token supply
- ERC-884 allows companies to use blockchain to maintain share registries
Non Fungible Tokens (NFTs)
These tokens are unique: each one can have a different value ant they are not replaceable. NFTs enable the tokenization of individual assets. They can often be found in games or you can imagine them as digital pieces of art, real estate… basically anything you like. Unique tokens can be further modified adding new “tools”, hence increasing their value overtime (like new bodyparts on a racing car). Check out our video on NFTs:
It became famous with CryptoKitties. The contract is composed by 8 functions plus 2 optional ones. Most of them are the same or similar to the Fungible counterparts, with few important differences.
8 mandatory functions:
- ownerOf(): retrieves the address that owns whichever NFT ID number is searched; ownership is defined by simply having the token
- takeOwnership(): transfer the tokens from another address that currently holds them
2 optional functions:
- tokenOfOwnerByIndex(): allows NFT IDs to be searched through a list of tokens owned by the user; it is necessary if we want more ntfs
- tokenMetadata( ): retrieves the metadata, i.e. info for identification
While when new ERC-20 tokens are created, the supply simply increases. In this case, things are more complicated. We have to monitor the metadata, and that is expensive in gas fees. ERC-721 defines a storing method.
A problem with this standard is that if we want to send more NFTs to someone, we will need as many transactions as the number of tokens sent.
Semi Fungible Tokens (SFTs)
In some cases, NFTs and FTs do not provide the required level of flexibility that is necessary to build new projects. As we have said, Fungible tokens are all “equals” while Non Fungible ones are unique.
But what if we need something that is neither Fungible nor Non Fungible? Like seat tickets?
Seat tickets (or supermarket vouchers, lottery tickets etc.) are 99% equal to on another with a very small difference, like a serial number that makes them unique, preventing double-spending/selling. When we buy a seat ticket, we don’t want someone else to have the same exact token and be able to use it if he arrives before us at the cinema.
In these circumstances Semi Fungible Tokens come in help: they hold their value until they are sold, changing from Fungible to not Fungible anymore.
The Multi Token Standard: ERC-1155
In all the other standards we have considered, we need to deploy a different contract for each type of token (one contract for all the same ERC-20s, one contract for each unique NFT). It is like being at the supermarket and not being able to buy all of the groceries we want at the same time, having to proceed one item after the other, from shelf to register, continuously. If we want to be able to buy a bunch of stuff at the same time, we need a new standard, and that is the ERC-1155. It allows for different “items” to be stored and created in the same contract (FTs, SFTs and NFTs), with the least possible amount of data; it is cheaper and more convenient.
For example, in a game we may exchange a currency (ERC-20) and/or NFTs (ERC-721) with other gamers; the ERC-1155 makes it possible. Moreover, it can execute a deterministic smart contract function by simply sending a token to an address (i.e. sending a token to an exchange address, the exchange could immediately return another token back to the sender’s address).
Practically, a single smart contract can mint infinite tokens forever (and it allows to save fees!)
Overall, among the Fungible tokens, some people think that the ERC-777 should be the designated one to become widely adopted. It offers, for example, more ways to protect our funds. Nevertheless, none of the above standards is without flaws and inherent risks. As a matter of fact, there are multiple reasons why ERC-20 is still the most popular one, and we can’t forget to mention that a new standard would create a lot of issues and interoperability problems, at least at the beginning.
If we consider the Non Fungible world, we are yet to see an explosion in adoption, but more and more platforms and games are coming out and it will probably be one of the trends of the next years. There are different platforms where you can go and buy collectibles directly with your Ethereum wallet (such as Metamask). One of the most famous and used is Rarible.
Only time will tell us which will be the next standard in use; proposing a solution and having the community embrace it are two very different things.