Ethereum was founded by Vitalik Buterin in 2014, positioning itself as an open-source platform for launching decentralized applications (DApps). Many of Buterin’s motivations for creating a new blockchain stemmed from the Bitcoin protocol’s lack of flexibility.
Since its launch, the Ethereum blockchain has attracted developers, businesses, and entrepreneurs, spawning a growing industry of users launching smart contracts and distributed applications.
In this article, we’ll look at the ERC-20 standard, an important framework for creating tokens. While it’s specific to the Ethereum network, the framework also inspired other blockchain standards, such as Binance Chain’s BEP-2.
What is the ERC-20 standard?
Authored by Vitalik Buterin and Fabian Vogelsteller in 2015, ERC-20 proposes a relatively simple format for Ethereum-based tokens. By following the outline, developers don’t need to reinvent the wheel. Instead, they can build off a foundation already used across the industry.
Once new ERC-20 tokens are created, they’re automatically interoperable with services and software supporting the ERC-20 standard (software wallets, hardware wallets, exchanges, etc.).
It should be noted that the ERC-20 standard was developed into an EIP (specifically, EIP-20). This happened a couple of years after the original proposal due to its widespread use. However, even years later, the name “ERC-20” has stuck.
A quick recap on Ethereum tokens
Unlike ETH (Ethereum’s native cryptocurrency), ERC-20 tokens aren’t held by accounts. The tokens only exist inside a contract, which is like a self-contained database. It specifies the rules for the tokens (i.e., name, symbol, divisibility) and keeps a list that maps users’ balances to their Ethereum addresses.
To move tokens, users must send a transaction to the contract asking it to allocate some of their balance elsewhere. For example, if Alice wants to send 5,000 BinanceAcademyTokens to Bob, she calls a function inside the BinanceAcademyToken smart contract asking it to do so.
Her call is contained inside what appears to be a regular Ethereum transaction that pays 0 ETH to the token contract. The call is included in an additional field in the transaction, which specifies what Alice wants to do – in our case, transfer tokens to Bob.
Even though she isn’t sending ether, she must still pay a fee denominated in it to have her transaction included in a block. If she has no ETH, she needs to get some before transferring the tokens.
Here's a real-world example of the above on Etherscan: someone is making a call to the BUSD contract. You can see tokens were transferred, and a fee has been paid, even though the Value field shows that 0 ETH has been sent.
Now that we’re up to speed, let’s take a look under the hood to better understand the structure of a typical ERC-20 contract.
How are ERC-20 tokens created?
Below are the functions as they appear in Ethereum’s purpose-built Solidity language.
function totalSupply() public view returns (uint256)
function balanceOf(address _owner) public view returns (uint256 balance)
function transfer(address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
In other words, you can authorize someone – or another contract – to transfer funds on your behalf. A possible use case involves paying for subscription-based services, where you don’t want to manually send a payment every day/week/month. Instead, you just let a program do it for you.
function approve(address _spender, uint256 _value) public returns (bool success)
Take our example of a subscription model again. Suppose that you have a huge amount of BinanceAcademyTokens, and you want to set up weekly recurring payments to a streaming DApp. You’re busy reading Binance Academy content day and night, so you don’t want to take the time every week to create a transaction manually.
At worst, if the DApp attempts to withdraw all your funds or if a bug is found, you can only lose twenty tokens. It may not be ideal, but it’s certainly more appealing than losing all of your holdings.
function allowance(address _owner, address _spender) public view returns (uint256 remaining)
The optional functions
What can ERC-20 tokens do?
A big part of the appeal of ERC-20 tokens is their flexibility. The conventions set out don’t restrict development, so parties can implement additional features and set specific parameters to suit their needs.
For a typical fiat-backed stablecoin, an issuer holds reserves of euros, dollars, etc. Then, for every unit in their reserve, they issue a token. This means that if $10,000 were locked away in a vault, the issuer could create 10,000 tokens, each redeemable for $1.
This is quite easy to implement in Ethereum, technically speaking. An issuer simply launches a contract with 10,000 tokens. Then, they’ll distribute them to users with the promise that they can later redeem the tokens for a proportionate amount of fiat currency.
Users can do a number of things with their tokens – they can buy goods and services or use them in DApps. Alternatively, they could request that the issuer exchange them right away. In that instance, the issuer burns the returned tokens (making them unusable) and withdraws the correct amount of fiat from their reserves.
The contract that governs this system, as aforementioned, is relatively simplistic. However, launching a stablecoin requires a lot of work on external factors such as logistics, regulatory compliance, etc.
Can you mine ERC-20 tokens?
The token distribution doesn’t need to be automated. Many crowdfunding events allow users to pay with a range of different digital currencies (such as BNB, BTC, ETH, and USDT). The respective balances are then allocated to the addresses provided by the users.
Pros and cons of ERC-20 tokens
Pros of ERC-20 tokens
This is ideal if your token aims to be a currency of some kind. You wouldn’t want individual units with distinguishable traits, which would make them non-fungible. This could cause some tokens to become more – or less – valuable than others, undermining their purpose.
As we explored in the previous section, ERC-20 tokens are highly customizable and can be tailored to many different applications. For instance, they can be used as in-game currency, in loyalty points programs, as digital collectibles, or even to represent fine art and property rights.
ERC-20’s popularity in the cryptocurrency industry is a highly compelling reason to use it as a blueprint. There are a plethora of exchanges, wallets, and smart contracts already compatible with newly-launched tokens. What’s more, developer support and documentation is abundant.
Cons of ERC-20 tokens
As with many cryptocurrency networks, Ethereum is not immune to growing pains. In its current form, it doesn’t scale well – trying to send a transaction at peak times results in high fees and delays. If you launch an ERC-20 token and the network gets congested, its usability could be impacted.
While not an issue with the technology itself, the ease with which a token can be launched could be considered a downside in some respects. It takes minimal effort to create a simple ERC-20 token, meaning that anyone could do it – for good or for bad.
As such, you should be careful with what you’re investing in. There are a number of Pyramid and Ponzi schemes disguised as blockchain projects. Do your own research before investing to reach your own conclusions on whether an opportunity is legitimate.
ERC-20, ERC-1155, ERC-223, ERC-721 – what’s the difference?
ERC-20 was the first (and, to date, the most popular) Ethereum token standard, but it’s by no means the only one. Over the years, many others have emerged, either proposing improvements on ERC-20 or attempting to achieve different goals altogether.
Some of the less common standards are the ones used in non-fungible tokens (NFTs). Sometimes, your use case actually benefits from having unique tokens with different attributes. If you wanted to tokenize a one-of-a-kind piece of art, in-game asset, etc., one of these contract types might be more appealing.
The ERC-1155 standard could be seen as an improvement on both ERC-721 and ERC-20. It outlines a standard that supports both fungible and non-fungible tokens in the same contract.
Other options like ERC-223 or ERC-621 aim to improve usability. The former implements safeguards to prevent accidental token transfers. The latter adds extra functions for increasing and decreasing token supply.
The ERC-20 standard has dominated the crypto asset space for years, and it’s not hard to see why. With relative ease, anyone can deploy a simple contract to suit a wide range of use cases (utility tokens, stablecoins, etc.). That said, ERC-20 does lack some of the features brought to life by other standards. It remains to be seen whether subsequent types of contracts will take its place.