Token ERCs in Ethereum: ERC-20, ERC-223, ERC-777 and ERC-721

Jean Cupe
Axionable
Published in
4 min readJun 8, 2018

An “Ethereum Request for Comments” — ERC — is the Ethereum’s version of Request For Comment (RFC) which is a memo for technical and organizational notes. Though, an ERC gives you some technical guidelines to work with and implement smart contracts on the Ethereum network.

Create a Token using an ERC on Ethereum should be an easy task if we use the only official token standard ERC-20 accepted in the Ethereum platform. Unfortunately, this standard has some security issues and new ERCs have been proposed to enhance the security and the ERC-20 token model.

EIP-20: ERC-20 The First Token Standard

This token standard was proposed in 2015, it was accepted last year and it has a final status since April 2018. (Accepted and final are EIP status terms defined here).

ERC20 functions and events.

This standard defines six functions that allow token transactions between different accounts. These functions were build to ensure the coherence and similar behaviour for the ERC20-based tokens in the Ethereum platform. Furthermore, it allows two ways of token transactions:

  • The transfer function can be used to send tokens to a wallet address.
  • The combination of ‘approve + transferFrom’ can be used to send tokens to smart contracts.

The bug of the ERC20 is related with the last type of transfer. Indeed, if you use the function transfer to send tokens to a smart contract, they can be lost. This is because the smart contract cannot withdraw the amount of tokens from your balance since the smart contract was not authorize to perform this action. This bug was reported by Dexaran who proposed the ERC223 to overcome this problem.

ERC-223: A standard proposal to improve security

The main goal of this token standard proposal is to prevent tokens loses during a token transfer. ERC223 wants to treat the token transfer in the same way as Ether transactions which means to handle each transaction as an event. This can prevent any token lose.

The interface of the ERC223 is not compatible with ERC20 as we can see in the following ERC223 code:

ERC223 functions and events.

The same transfer function in ERC223 can be used for both wallet address and smart contract, and it will avoid any invalid transfer because it will throw an error which cancels the transaction and no funds are lost. This behaviour will improve the security problem found in ERC20.

Indeed, the transfer function can check now if the receiving address is a smart contract or not. If it is the case, the transfer function will try to call a tokenFallback function from the smart contract. The tokenFallback function allows the return of sent funds to the smart contract. It this function does not exist on the smart contract, the transaction will fail. Otherwise, the transaction will succeed.

ERC-777: A New Advanced Token Standard

The ERC-777 standard proposal fixes the send-tokens-to-contract bug found in ERC-20. It is based on the ERC-820: Pseudo-instrospection registry contract, and it is focused on adoption and better transaction handling.

ERC-820 defines a central registry of contracts in Ethereum network, and everyone can use this registry to check a contract interface which allows to know all the supported functions in the contract. ERC-777 uses this approach to perform any token transaction and it checks if a contract has a tokensReceived function implemented (this function is the equivalent to the tokenFallback in ERC-223).

ERC777 functions and events.

The ERC-777 defines new functions such as send and authorizeOperator which replace respectively the functions transfer and approve from ERC-20. A new set of functions guarantees a compatibility with earlier standards avoiding any cross and function overwrite problem.

ERC-721: Non-Fungible Token Standard

ERC-721 is a proposal standard for non-fungible tokens which are tokens that are defined by their uniqueness and rareness. This post explains really well this standard and it makes an analogy of non-fungible tokens with collectible items. The value of a token will be defined according its characteristics and rareness and one application that uses this type of tokens is the famous CryptoKitties Dapp.

This standard defines some ownership functions that allow to handle token ownership and ownership transfer. It is possible to also use a metadata function with this standard which allows us to see the set of attributes of a token that make it unique.

ERC-721 standard guides us in the implementation of non-fungible tokens which have become very popular in some Dapps such as CryptoKitties nad CryptoPunks.

Conclusion

There is only one official token standard on Ethereum, the ERC-20 standard. This standard is quite a good guide to create a first token on Ethereum. However, it is very important to consider other standard proposals especially to overcome the shortcommings of the first standard such as the send-tokens-to-contract problem. Furthermore, the standard to use will depend of the application that can be used in some cases non-fungible tokens.

Thanks to read this post! If you have any questions, I’ll be happy to answer them in the comments.

Jean for Axionable.

P.S.: If you wanna know more about Axionable, our projects and careers please visit us or follow us on Twitter.

--

--