What are ERC-20 Tokens? A Beginner’s Explanation
By: Steven Hay | Last updated: 1/25/23
ERC-20 tokens are standardised Ethereum-based tokens that are compatible with most of the wider ecosystem. In this post, I’ll explain the ERC-20 standard and how ERC-20 tokens are used.
What are ERC-20 Tokens Summary
ERC-20 tokens have streamlined the way we create and use Ethereum-based tokens, through a common and widely-compatible standard. This ERC-20 standard has led to a surge in new project tokens and token sales, making it easy to build and raise funds on the blockchain.
That’s ERC-20 tokens in a nutshell. For a more detailed explanation, keep on reading. Here’s what I’ll cover:
- What are ERC-20 Tokens?
- Why the Need for the ERC-20 Standard?
1. What are ERC-20 Tokens?
Token sale methods such as Initial Coin Offerings (ICOs), Initial DEX Offerings (IDOs) and others have become extremely popular ways to raise funds, while avoiding the regulatory restrictions of fiat financing. More than $30 billion was raised in the first three years of Ethereum ICOs alone, with several billion more being raised through similar methods.
The majority of token sales are based on Ethereum as a platform, and more specifically on Ethereum’s smart contracts. Shares in new projects are usually sold for ETH or stablecoins, and awarded in the form of tokens (also known as ERC-20 tokens).
For newcomers to Ethereum, we usually recommend using MyEtherWallet.com (MEW) to monitor and manage ERC-20 tokens. For optimal security, MEW is best paired with a hardware wallet.
So while we’re used to seeing and dealing with ERC-20 tokens, few people know exactly what they are, how they work, or even what ERC-20 means. In case you’re wondering, ERC stands for “Ethereum Request Comment”, and “20” is the arbitrary number assigned to the proposal.
As the name implies, the native currency of Ethereum blockchain is Ether (ETH). But ERC-20 tokens also act as additional currencies on Ethereum. Ethereum is the heart and mind of ERC-20 tokens. Its blockchain processes their transactions, and its virtual machine runs their smart contracts.
Ethereum.org’s depiction of an ICO or “trustless” crowdsale:
Customers pay the smart contract (the robot in the center).
The robot forwards the money to the contract owner.
The robot returns the owner’s ICO tokens to the customers. Neat!
Remember that these tokens aren’t independent. They reside on Ethereum’s blockchain, and depend on its distributed computing abilities.
Smart Contract Risks
While smart contracts are very efficient, they do come with risks. For instance, a smart contract is difficult to change once it has been initiated by the ICO’s developers. If a smart contract contains bugs or vulnerabilities, you could easily lose your funding, tokens, or both.
Such misdeeds have frequently occurred throughout Ethereum’s history. The most famous early example was the $55 million DAO hack, and correcting it required a hard fork of the Ethereum network (which is how Ethereum Classic was created). More recently, several DeFi protocols have suffered from smart-contract exploits, resulting in billions of dollars in losses.
2. Why the Need for the ERC-20 Standard?
Before the ERC-20 standard came about, there were many compatibility issues among the various forms of Ethereum tokens. Each token had a completely unique smart contract. In other words, it had to write completely new code for each exchange or wallet, in order to host a new token. And supporting the increasing array of tokens was becoming excessively problematic and time-consuming.
As a solution, the industry came up with a standard protocol for all tokens to follow, which is now known as ERC-20.
The ERC-20 Token Standard has six obligatory parameters for any smart contract, plus three optional (but recommended!) ones. Optionally, you can set the maximum number of decimals that a token supports. To compare, Bitcoin allows for eight numerals after the decimal point, as well as its symbol (usually a 3- or 4-character code) and its name (so choose something inspiring!).
The six compulsory functions deal with the number and transfer of tokens. The first two are used to allocate the initial state of token distribution:
- The totalSupply function of the token must be set. After the maximum is reached, no more tokens may be created by the smart contract.
- The balanceOf function assigns an initial number of tokens to any given address, usually the owners of the ICO.
Two transfer methods are also needed for additionally distributing to users and sending tokens between users. They’re vital for secondary market functions:
- The transfer function moves tokens from the total supply to any individual user who purchases during the ICO phase.
- The transferFrom function is used to send tokens from one person to another.
Two further functions are required to verify functions 3 and 4:
- The approve function checks that a smart contract can distribute tokens, based on the remaining supply.
- Lastly, the allowance function makes sure that an address has enough of a balance to send tokens to another address.
These 6 simple steps have allowed wallet providers and exchanges to create a single codebase, which can interact with any ERC-20 smart contract.
ERC-20 Token Applications
ERC-20 tokens have many uses. For example, they can act as project shares, asset-ownership certificates, loyalty points, or even just pure cryptocurrencies. It’s also possible for ERC-20 tokens to simultaneously fulfil several of these roles.
ERC-20 Token Creation
All tokens are created by smart contracts. These smart contracts handle the token’s transactions, and account for the balance of every token holder.
While an ICO is active, you should receive the ICO’s tokens back at the agreed-upon exchange rate, if you send crypto funds and your details (most importantly, your mailing address) to its smart contract.
Other token sale methods involve direct listing on exchanges, which may have variable exchange rates.
Problems with ERC-20 Tokens
The ERC-20 protocol alone isn’t always sufficient for a token’s purposes. It’s only a standard for creating Ethereum-based tokens, and it doesn’t ensure useful, valuable, or even functional tokens.
A token may still be further customized, as long as it meets the ERC-20 basics. One downside of the ERC-20 standard is that it makes deploying a token trivial on a technical level. As a result, many teams who would have been otherwise incapable of launching a token have been able to. The sheer number of deployed tokens (533,514 and counting!) leads to an abundance of very similar tokens, which makes the selection process harder and more confusing for prospective investors.
Another problem is that some projects implement the guidelines in an idiosyncratic way, which creates more confusion about the way their tokens operate. For example, tokens are sometimes sent to the smart contracts of other projects. If that contract hasn’t allowed for this eventuality, then the tokens will be lost. The ERC-223 proposal was one attempt to counter this flaw.
The creation of the ERC-20 Token Standard has accelerated growth across the entire token offering space. This standardization of functions has made it much easier for new projects to develop tokens, as well as sell them to raise funds.
The protocol has also managed to bring an enhanced synergy among new projects, exchanges, and wallet providers. As a response to common problems and vulnerabilities in Ethereum tokens, the ERC-20 protocol will probably be enhanced and extended in the future.