Over time, the blockchain increasingly penetrates into our lives, and it becomes necessary to understand its main technologies, including the work of decentralized applications (dApps). Most dApps are currently created on Ethereum, the capabilities of which are much more flexible than issuing the usual ERC20 tokens.
Why standards are needed
Inside the smart contract, you can write the unique mechanics of the token. It will work, but other developers (and smart contracts) will not be able to access it using generic logic.
Example: you created a token for a game item (decentralized gaming is actively developing now) and you want it to be able to trade on marketplaces for in-game items (something like that ). But marketplaces don’t know how to access functions within your contract, they need a separate smart contract to support your token.
Standards come to the rescue. Knowing how to interact with them, the creators of other dApps have put in the code everything you need to work with a token on a certain standard.
How standards come about
Ethereum is an open-source project (by the way, ERC is Ethereum Request for Comments), so it is logical that any user can propose a new token standard. If the standard solves some important problem, then it can become the official Ethereum standard (that is, get on this list).
Fungible and non-fungible tokens
The starting point for classifying token standards is their interchangeability or lack thereof. Fungible tokens are equal to each other and can be used as currency. Semi-fungible (half fungible) tokens are almost indistinguishable from each other, but still unique (for example: tickets in a cinema, the cost may be the same, but each has a unique place). Non-fungible (non-fungible) tokens are completely unique, a tokenized object in a single copy (example: copyright objects).
If you don’t recognize the kitten, then this is one of the first games on Ethereum (and the ERC-721 standard), CryptoKitties .
The most famous standard for fungible tokens is ERC20, which was proposed by the author of the Ethereum idea Vitalik Buterin back in 2015. This token is widely used for various types of initial offering (first proposal). I avoid the terms ICO and IEO, because now these are far from the only ways to conduct a public offering of tokens (but this is not the article about that).
Specificity: an interchangeable standard, there is a ticker for exchanges, divisible (the number of decimal places is determined by the creator of the smart contract), must have a total supply (the number of tokens that cannot be issued more).
ERC-721 was proposed as an EIP (Ethereum Improvement Proposal) by Dieter Shirley in 2017, became official in 2018.
Specifics: not an interchangeable standard, no ticker, indivisible, necessarily exists only in a single copy.
ERC-721, like ERC-20, is widespread, so I will not dwell on it.
This format is an “improvement” of the familiar ERC-20. It is backward compatible with ERC-20, but has several advantages:
- when exchanging tokens, it uses one transaction instead of two in ERC-20;
- automatically cancels transactions for incompatible contracts;
- the ability to mark unreliable addresses;
- the ability to appoint operators (addresses that have the right to send tokens from another address);
- accelerated transactions.
Also an “enhancement” to ERC-20, preventing the sending of transactions to random contracts. If the smart contract does not have functions for working with tokens, then they are returned to the sender.
The idea for this standard was proposed by the developers of the Enjin project in 2018. Enjin is a project that aims to simplify the creation of games on Ethereum. Therefore, the standard proposed by them should first be considered as a game standard, although its application is not limited to this.
- allows you to issue multiple tokens in one contract;
- tokens in one contract can be fungible and non-fungible at the same time;
- supports atomic swaps;
- supports “batch” transactions;
- not all transactions need to wait for the end of the block.
If the first two points are clear, then the third and fourth can raise questions. Let’s start with atomic swaps.
One of the reasons for the rejection of the blockchain everywhere is the inability to quickly and efficiently (in terms of fees) exchange one token for another (and the number of different tokens is increasing all the time). The solution to the problem has already been created – these are atomic swaps. Usually, Atomic swaps are understood as the technology of decentralized exchange between cryptocurrencies of different independent blockchains ( it is well written about this on BitcoinWiki ). But it is also worth considering atomic swaps in the context of exchanging tokens within a smart contract.
The picture from the Enjin blog illustrates the ERC-1155 multiple token swap.
And batch transactions, although they do not save time, they save gas by writing several transactions to the network as one.
It is worth mentioning that although ERC-1155 has become more widespread, it borrowed a lot from the ERC875, which appeared a few months earlier. ERC-875 offered the same functionality besides supporting fungible tokens.
A standard similar to ERC-20, but uses not gas for commissions, but the tokens themselves. Due to the complex gas commission payment system (the gas price is chosen independently), and sometimes the unpredictability of the commission size, such an improvement can be very useful for accepting tokens on Ethereum.
I have not considered all the standards, but if we talk about all ERCs, then they are mostly similar to each other, and offer either a solution to ERC-20 problems, or an application in some separate niche. If you want to read the code in detail: Github EIPs , Github OpenZeppelin . Ethereum.org .