Complete Guide To ERC-20 standard for Ethereum network (2023)

Complete Guide To ERC-20 standard for Ethereum network (2023)

Mastering the ERC-20 Standard: Your Ultimate Guide to Navigating Ethereum's Network

Whether you are learning about Blockchain, exploring web3 or investing in Cryptocurrencies. ERC20 Tokens and its standard is often a topic of debate and discussion among web3 enthusiasts, developers and investors. At its core, it is just a set of guidelines to create Ethereum-specific multipurpose assets.

These assets help to make Decentralized applications i.e, dApps interact over different platforms simultaneously. We can buy and sell them on different kinds of Exchanges, and we can store them in wallets without writing any custom code for each token or asset.

Now don’t worry if you are not familiar with the few words above. Because in this article I’ll give a brief introduction to Ethereum, ERC20 Standard and everything in between.

The Ethereum Blockchain

Ethereum at its core is an open peer-to-peer network of nodes or computers. The network nodes have Ethereum Virtual Machines (EVMs) installed on them to run these small computer programs called contracts. Though there are significant differences, the basic idea behind the Ethereum network and Bitcoin is the same. Similar to Bitcoin, there is no central authority in the Network.

Individuals who participate facilitate the transfer and documenting of transactions. They then mine blocks to store all that critical data in a chain of Blocks. These blocks are secure through a cryptographic Hash. It requires a lot of computing power to unlock these blocks.

Such a constraint and honest nodes control a major portion of computing power. It inturns ensures security from potential Hackers. This is the reason blockchain like Ethereum is immutable. Once we write something on Blockchain and hash it then we can not change it.

Basic Structure of a Blockchain

Basic Structure of a Blockchain

Unlike Bitcoin, Ethereum provides resources to make decentralized applications (dApps). These dApps use the programming language Solidity. These dApps may have their tokens given to people interested in the project as proof of ownership.

Ethereum has inherited all the features of the Bitcoin blockchain. It has evolved and improved by incorporating smart contracts. frequent adoption of various network standards like ERC20, ERC721, ERC1155 makes the network robust.

Tokens

Tokens can be defined as a digital item that is precious to us. They represent some value. The value a particular token inhibits is subject to the purpose it serves for the project it was coded or created for.

Tokens and cryptocurrencies are not always similar Their use cases define if they are identical or not. But they are assets that we can hold or use to get ownership and so much more. There are various types of tokens for different uses and each of them quantifies something of value.

Types of Tokens

  • Utility Tokens

    Utility tokens can be seen as coupons that one can use as an exchange medium to avail of the benefits of a service or buy a product. These tokens are not investment instruments and can lose value anytime. You can get the service or product of the same value as the utility token but you don’t own it yourself.

    For Example, think of going to an Adventure Park with many Rides and Games. You buy a token for the game you want to play or any ride. You buy a ticket for that using your physical money. In this case, the ticket you buy is a utility token which you are exchanging for enjoying your time in that Adventure Park.

    Security Tokens

    Security Tokens are secure cryptocurrencies. Their value depends on the external asset that we can trade under the regulation of a Financial authority. Stocks, Bonds, Derivatives etc are a few examples of such assets under the regulation of The Securities and Exchange Board of India (SEBI).

    They generally maintain transparency to secure a stake in equity, dividend income and voting rights. They help in the instant settlement and division of assets.

    Payment Tokens

    They represent all the cryptocurrencies and the majority of Tokens. These tokens help us to buy and sell things digitally without any central authority like Banks. Bitcoin (BTC) and Ether (ETH) are examples of popular payment tokens.

    Exchange Tokens

    As the name suggests These Tokens are available in Crypto exchange marketplaces for selling, buying and swapping Tokens. They serve as a common standard for the exchange for all the transactions or for gas payment I.e., payment for computational power we use.

    Binance Coin, FTX Coin, Uni Token and CRO (Crypto.com) are a few examples of Exchange Tokens.

    Non-Fungible Tokens (NFTs)

    NFTs allow multiple interested parties to share an asset that holds unique value. It is similar to collecting antiques, watches, paintings or any other art piece. But the only difference is that many people. Best NFTs are those that are highly valuable owing to their uniqueness and belong to a single individual or a small group of people.

    Artists can create NFTs of their art pieces and sell them digitally through NFT marketplaces OpenSea, DeCentraland, Foundation etc.

    Stable Coins

    The value of these coins is not volatile and remains stable. This is because Fiat currencies like the Dollar, Euro and commodities like Gold, Silver, Oil etc. support these coins. The supporting entities that back the Stable Coins monitor and control the exchange rate or conversion ratio to keep the price stable.

    Need for a Standard?

    ERC20 Tokens

    Before we understand what the ERC20 standard is we need to know why we even need it. Let’s see what ERC20 assets are and their use cases.

    The ERC token is nothing but a way to show the value of something important. Tokens can also act as incentives and local means of transferring wealth. ERC tokens exist on the Ethereum platform. Tokens are interdependent on Ethereum for its infrastructure**.** The native currency on the Ethereum network is Ether (ETH). Different tokens on the network work as a currency, as Loyalty points, shares of a company, and Gold certificates.

    ERC20 has been widely in use since its introduction in 2015 for Initial Coin Offerings (ICOs) which is distributing tokens from initial supply to some interested stakeholders, and builders to get funding to build the project. This is known as tokenization and is a changing face of the funding and investment domain. Builders can use their tokens to participate in decision making and asset owners can also sell their tokens to show their dissatisfaction with the project if it does not meet their threshold progress.

    Smart Contracts

    Smart contracts are small computer programs in the Solidity programming language to create tokens. These programs create tokens and manage transactions related to them. They also manage the balances of the token holders. To get some tokens, you need to send ether (ETH) to the smart contract, which will then give you a certain number of tokens in return.

    Skeleton of Ethereum EcosystemThe Skeleton of the Ethereum Ecosystem

    Once a smart contract is created, it can not be altered. This means we can not change the code of smart contracts. If we have a bug in our code that allows people to steal tokens or doesn’t record account balances correctly. Then this issue is unchangeable, we can’t fix it. That is why we must remain cautious before deploying a smart contract to avoid any blunders or mistakes.

    Then there is an interoperability issue. Each token contract can be different from the others, and if you want your token to be available on every exchange, they need to write custom code to interact with your contract and allow people to trade. The same applies to wallet providers. Writing custom code for every new token that comes to exchange can be time and resource-consuming. These are the reasons to adopt this standard.

    ERC20 Standard

    Ethereum has a public forum on Github that allows its participants to submit proposals and requests for changes in its blockchain to improve it. These proposals are Ethereum Improvement Proposals or the EIPs. These proposals are discussed thoroughly by the community and if passed they are called Ethereum Request for Comment or the ERC.

    The ERC20 was the 20th EIP since the beginning of the discussion forum. Its genesis provides a solution for creating interoperable tokens that are available on any asset or token exchange and wallet without writing custom code for every new token on Ethereum.

    There are 6 mandatory and 3 optional functions as per the ERC20 standard. Think of the ERC20 standard as a Java Interface. If you want your token to be an ERC20 token, then your smart contract must implement those 6 mandatory methods.

    A Token Contract

    Optional Functions

    1. Token Name: This method allows us to give a name to our Token. e.g – Bitcoin, Ethereum etc.

    2. Symbol: This method allows us to give a symbol to our token to represent it visually. e.g – BTC, ETH etc.

    3. Decimal: This method allows us to set up to what decimal place we can divide our token. It defines the minimum amount that can be exchanged.

Standard Functions

  • totalSupply: This method allows us to set the total amount of tokens we want to create.

Total Supply Method

  • transfer: This method allows us to send a specific number of tokens from the total supply to a user.

Transfer Method

  • balanceOf: This method returns the number of tokens a user has in their account.

balanceOf Method

  • transferFrom: This method is very similar to the Transfer Method. It allows the transfer of tokens from one user’s account to another.

transferFrom Method

  • approve: this method checks transactions by comparing it to the total supply so that there are no extra or any fewer tokens than specified in the contract.

approve Method

  • allowance: this method checks if the user sending tokens to someone else has enough tokens in his account to send. If the user has insufficient funds then the transaction does not take place.

allowance Method

Limitations of ERC20 Standard

Although people continue to use ERC20 on a big scale, it is not perfect. It still lacks a transaction management system.

  • If a Transaction happens using the transfer function then the recipient is not notified that he has got his amount.

  • Another problem is that even if a smart contract does not follow ERC-20, it can accept tokens. if a user sends a token to it by mistake then funds are frozen forever and can not be retrieved.

  • Web3 developer Dexaran has critically highlighted problems with ERC20 here: dexaran820.medium.com/erc20-token-standard-..

Conclusion

Different kinds of tokens can be used for different purposes. ERC20 aims at increasing interoperability by specifying 6 standards and 3 optional functions every Token contract must follow so it can be made available on every Exchange and wallet.

  • But the standard has some loopholes that lead to security issues and double-spending. Thus better standards are being introduced. ERC223 is one such standard developed by Dexaran and it handles transactions similar to ETH transactions.