When reading the description of any ICO, you will most likely come across the abbreviation “ERC-20”.
Moreover, ICO organizers often mention the “create ERC20 token standard” as an advantage of a cryptocurrency token. Sometimes you can see the character sequence “ERC-223”. Does this mean that an ERC-223 token is more than 10 times better than an ERC-20 token? And what does ERC mean? Let’s find out!
Cryptocurrency tokens
From the user’s point of view, tokens differ little from cryptocurrencies and are perceived as an additional currency with special properties. There are many different tokens, some of which are traded on exchanges and can be purchased and transferred between each other. Very similar to cryptocurrencies, but from the point of view of the Ethereum network, a cryptocurrency token is data from a program, more precisely, a smart contract.
For example, for Alice to transfer ether to Bob, Alice creates a message “I am Alice, I am transferring to Bob 1 ether that I received from Charlie,” signs it with her private key and sends it to the network. Network participants check Alice’s signature, verify that the ether received from Charlie was not spent, and, using mining, record the transaction in the blockchain, confirming it.
For Alice to transfer Bob, for example, a Golem token, Alice creates the message “I am Alice, I am sending a message to the Golem smart contract. Golem, transfer one token from my account to Bob’s account,” signs it with his private key and sends it to the network. This message is not a transaction, Alice is not transferring anything to anyone yet, she “wrote a letter” to the smart contract. And after checking Alice’s signature, the Golem smart contract wakes up.
Golem is a full-fledged program, although it runs on a virtual machine. It has its own database, which records how many tokens belong to and who owns it, and it has its operating algorithm, which was written by Golema programmers. Her algorithm may well have a condition not to transfer tokens to Bob on Fridays or (which is more often used) not to transfer tokens from Alice’s account until 2020 (asset freeze). These tokens essentially do not exist on the Ethereum network. For a virtual machine running a smart contract, the number of tokens in Alice and Bob’s accounts is just the value of variables in one of the thousands of programs.
All operations in smart contracts are carried out using commands. For Alice to find out how many tokens she has, she needs to send a message to the smart contract and receive a response from it.
Feeling the opportunities that smart contracts provide, thousands of developers began to develop their programs for the Ethereum virtual machine, including new “token management programs.” But because of the flexibility of the language, everyone wrote “token management programs” in their way. Some had the function for getting the balance “balance (account_address)”, some had “money(account_address)”, and others did not implement the ability to find out the balance at all. Smart contracts are full-fledged programs, and the code can be written in any way you like. The more tokens became available, the clearer it became that tokens needed a standard. ERC-20 became such a standard.
ERC-20
ERC stands for Ethereum Request for Comments, which is a discussed solution for Ethereum. 20 — because it was the 20th question for discussion in order. ERC-20 was initially an informal agreement between developers but is now a standard.
For a “smart token management contract” to comply with the ERC-20 standard, it must:
When calling the totalSupply() function, that is, sending such a message to the smart contract, report the total number of issued coins.
On balance (address owner) report the number of tokens at the owner address (you need to specify the address instead of _owner).
When calling transfer(address to, uint256 value) , send from the caller’s address the amount value to the address to.
When calling transfer from (address from, address to, uint256 value), send the number of value tokens from address from to address to. The caller must have permission to transfer funds from the owner of the _from the address, which is set by the following function.
When calling approve(address spender, uint256 value), transfer the right to the user with the address spender to transfer the number of value tokens from the address of the function caller. Used to transfer the right to manage tokens.
When calling allowance(address owner, address spender), report how many coins the owner has allowed the user spender to transfer from his account.
Include in your smart contract the variable name (full name of the token), symbol (short name of the token) and decimals (how many decimal places are taken into account in the quantity).
Trigger two events Transfer (for any movement of tokens) and Approval (for transferring the right to transfer someone else’s tokens).
These are all the rules of the standard. That is, if you know that a token is ERC20 token development compliant, you can communicate with the smart contract that manages it using these commands. There may be more commands, but all of the above must be present, and the token must respond to them as the standard dictates.
To use an analogy, imagine if there were no standards for car controls. Every time you got into a new car, you would look for the gas and brake pedals, and they could be on the steering wheel, or above your knees. Instead of a steering wheel, there could be a joystick, and the turn signals could be turned on using buttons on the armrests. For each car, you would have to learn to drive again. Fortunately, some standards ensure that drivers do not feel much discomfort when changing cars.
ERC-223
Even before ERC-20 became a standard, ERC-223 appeared. Again, the numbers here are just sequential numbers. ERC-223 is intended to improve ERC-20 and become its successor. For some time, the standards developed in parallel and some of the improvements from the new standard were transferred to the “big brother”. Currently, there are only two differences.
Firstly, in ERC-20 it is possible to send tokens to the smart contract address rather than the user. In this case, the sent tokens hang at the smart contract address, and nothing can be done with them. It would seem that it is their fault — they do not look where they are sending, but at the moment millions of dollars worth of tokens are stuck. ERC-223 solves this problem.
Secondly, ERC-223 slightly reduces gas consumption for requests.
The ERC-223 standard is backward compatible with ERC-20 and is, so to speak, its extension. Sooner or later, all tokens will switch to ERC-223.
ERC-721
The ERC-721 standard token is different from those described above.
ERC-20 and ERC-223 are used to create “faceless” tokens, each of which is indistinguishable from the other, much like two new bills or two dollars in a bank account.
Each ERC-721 token is unique and can be used for collecting or declaring ownership. You need to communicate with the smart contract that manages ERC-721 tokens differently — not using numbers, but specifying the 256-bit identifier of each token. Tokens can only be moved one at a time and, logically, tokens cannot be divided into parts.
The standard is used in the popular game CryptoKitties, where each token corresponds to a cat with a unique appearance. Cats can be bought, bred and sold. It doesn’t sound very interesting, but some cats were sold for $100,000, and at the peak of the game’s popularity, the Ethereum network had difficulties conducting transactions — the network was overloaded.
Bottom line
It was thanks to the ERC20 token development service standard that we saw explosive growth in the ICO market in 2017. The presence of a standard allows you to build an ecosystem around this standard, in which creating a new token and adding it to exchanges costs almost nothing. Considering that several thousand tokens have already been produced, the question may arise as to whether this is a good thing. However, the emergence of a token that does not support ERC-20 or ERC-223 standards is now unlikely.