Topics In Demand
Notification
New

No notification found.

Introduction to Token Standards: ERC-20, ERC-721, ERC-777, and ERC-1155
Introduction to Token Standards: ERC-20, ERC-721, ERC-777, and ERC-1155

October 28, 2022

544

0

 

In the last few years, Bored Apes Yacht Club, CryptoPunks, and many other tokens have popularised Non-fungible tokens. But what are these tokens anyway?  

In this writeup, we’ll be learning about the fundamentals of tokens, what are fungible & non-fungible tokens, what are the various token standards (ERC & EIP) developers must adhere to, and much more. 

Why are Tokens and Coins Needed in Blockchain?

Tokens are essentially digital assets defined by smart contracts and built on a particular blockchain. Tokens are usually a faster way to leverage existing standards of a successful blockchain while building digital assets and they are often used to create smart contracts on dApps. 

There are five major kinds of tokens, namely Reward tokens, currency tokens, utility tokens, security tokens, and asset tokens. 

If you’re wondering how similar coins are to tokens, they’re drastically different, let me explain:

While ETH is the coin built by Ethereum on its own blockchain, Basic Attention Token (BAT), Bancor (BNT), OmiseGO (OMG) and others are tokens built on top of the Ethereum blockchain. That’s how coins are different from tokens.  

What are Token Standards?

Now that the fundamentals of tokens are clear, let us understand what smart contract standards which are essential to comprehend token standards. 

Smart contract standards are stipulations & rules a contract must adhere to function appropriately on the blockchain. Said standards are app-level specifications such as name registries, library-package formats, and token standards. 

When developers adhere to the set smart contract standards of Ethereum, they can create their own ERC token, enabling the smart contract to perform basic functions. 

Now that we know that token standards fall under smart contract standards, we can finally understand what token standards really mean.

Token standards are sets of rules, guidelines, and stipulations developers need to follow to create, issue and deploy tokens on blockchains that support smart contracts.

With that said, Ethereum is the most commonly used blockchain platform, and these are the various generations of standards developers have and must adhere to- ERC-20, ERC-721, ERC-777, and ERC-1155. 

What are ERC and EIP Standards?

ERC (Ethereum Request for Comment) is technical documentation that dictates guidelines and rules for creating & deploying a smart contract on the Ethereum blockchain. 

With that said, anyone can add or create a new ERC, but it is vetted by people’s votes and support known as EIP (Ethereum Improvement Proposal). 

Under EIP, all network participants of Ethereum can see the improvement proposal and decide if it adds value and improves upon the existing ERC. 

Once the Ethereum developers and community deems your improvement important, it will be accepted and implemented for everyone to take advantage of the new ERC standard. 

Some of the commonly used ERC standards are: 

ERC-20 Token Standard

The ERC-20 standard is predominantly used as the fundamental framework for building fungible tokens on the Ethereum blockchain. 

Each fungible token or a fraction of said token holds equal value to another. For instance, a $10 bill in person A’s pocket holds the same value as a $10 bill in person B’s pocket, and it is said that this $10 bill is fungible. Essentially, all fiat currencies are fungible; the same goes for 10 ETH, which holds the same value as another 10 ETH. 

Anyone can deploy a ERC-20 token and create custom token utility. It can be used for granting voting rights, reward network participants, and other on-chain activities. Majority of the big name tokens were first launched as ERC20. Stable coins like USDT, USDC, BUSD, governance tokens like MKR, UNI, or utility tokens like BAT- all are ERC20 compliant.  

These are the six functions every ERC-20 token must implement: 

  1. TotalSupply(): The total supply number of ERC-20 tokens
  2. BalanceOf(): The balance or the total number of tokens in a wallet
  3. Transfer(): Enables transference of tokens from the caller’s account to another account 
  4. TransferFrom(): similar to transfer() but allows smart contracts to transfer tokens on the owner’s behalf
  5. Approve(): sets a limit on the number of tokens a user is allowed to spend
  6. Allowance(): the total number of tokens a user is allowed to spend on the owner’s behalf

Other than the above-mentioned functions, the optional functions that can improve the usability of ERC20 tokens are Token Name, Ticker Symbol, Decimals, and Divisibility. 

The above functions form the foundation of an ERC-20 contract, as an extension, the foundation to build cryptocurrencies, stablecoins, utility tokens, and others. 

ERC-721 Token Standard

Unlike ERC-20, ERC-721 is the token standard used to create non-fungible tokens, popularly known as NFTs, on the Ethereum blockchain. 

NFTs are cryptographic tokens that are unique in nature and don’t share value with any other token similar to them. This means NFTs carry a unique value, like the painting of the Mona Lisa or other artwork that isn’t mass-produced. More details on the difference between Fungible and Non-fungible tokens are shared further down the article. 

The basic ERC-721 functions are 

  1. BalanceOf(): The balance or the total number of tokens in a wallet
  2. OwnerOf(): Owners TokenID
  3. SafeTransferFrom(): Transfer tokens from the owner’s wallet to the receiver’s account. 
  4. TransferFrom(): similar to transfer() but usually not recommended
  5. Approve(): triggers approval events
  6. SetApprovalForAll(): enables the operator to call SafeTransferFrom
  7. GetApproved(): gets the approval for the specific tokenID
  8. IsApprovedForAll(): verifies if the operator has the authority to manage the assets of the owner

ERC-721 also contains functions like Transfer triggered when the owner of the NFT changes, and Approval which triggers when the approved address changes.

Cryptokitties, Beeples $69.3M worth NFT, Decentraland NFTS have used ERC721 standard. 

What are Fungible and Non-fungible Tokens? 

The fundamental way to describe fungible tokens is that no single token is worth more or less than the other. Fungible tokens are also divisible digital assets, meaning you can exchange these with the same type of assets, and the value would remain the same. For example, two dollar bills that hold the same value. 

Whereas NFTs are a different story. NFTs are digital assets that can’t be exchanged because of their uniqueness. There is only one NFT of its kind; hence, it holds value due to its unique status. You can consider a rear painting by Vincent van Gogh or Rembrandt as examples. 

The below graphic will make it easier to understand the difference between the two: 

ERC-777 Token Standard

The ERC-777 is another fungible token standard created to resolve the limitations set by ERC-20. ERC-777 uses a mechanism called “Hooks” to make smart contracts more efficient in sending & receiving tokens. 

The token is also backward compatible with ERC-20, rendering the latter obsolete. This means that fungible tokens created on ERC-20 freely interact with the ones built on ERC-777, as both use the same functionality. 

  1. Granularity(): the smallest portion of the token that isn’t divisible
  2. Send(): sends a specific portion of tokens to recipients.
  3. Burn(): kills a specific portion of tokens that reduces totalSupply
  4. IsOperatorFor(): verifies if an account is operator
  5. AuthorizeOperator(): turns an account into an operator
  6. RevokeOperator(): revokes the account’s operator privileges
  7. DefaultOperators(): returns lists of holders who are operators
  8. TokensToSend(): triggered when tokens are about to be moved from a holder’s account or destroyed. 
  9. TokensReceived(): triggered when tokens are about to be moved to a holder’s account or destroyed. 

This token standard has many security issues and susceptible to hacks. Instead of this, an updated version ERC820 can also be used. 

ERC-1155 Token (Multi-Token) Standard

ERC-1155 basically addresses two pain points that persist in the previous iterations of token standards. 

1. Support batch transfers of multiple assets in one smart contract. 

2. Performs functions of both ERC-20 and ERC-721 token standards. 

This means ERC-1155 can transact multiple tokens in a bundle or an infinite number of tokens, unlike ERC-721, which requires multiple transactions. The latter would not only congest the network but also cost significantly more gas fees. 

ERC-1155 not only reduces gas fees and increases transaction speeds but also improves the functionalities of both its predecessors, being more efficient from all angles. 

The best thing about ERC1155 is, you can create semifungible tokens with this standard. Semifungible tokens are a kind of token that can be used as a fungible token at the time of  trading and becomes NFT if redeemed. It addresses the undivisibility factors of NFTs and make fraction selling possible. 

The basic ERC1155 functions and features are as follows: 

  • BalanceOfBatch(): returns the balance amount in a batch with IDs
  • SetApprovalForAll(): allows operators to transfer caller tokens
  • IsApprovedForAll(): verifies if the operator can transfer caller tokens
  • SafeTransferFrom(): transfers tokens from the caller’s address to the receiver’s address. 
  • SafeBatchTransferFrom(): functions the same as the above SafeTransferFrom() except in batches.

Many of todays blockchain games are using this token standard. Adidas originals also used this standard for their NFTs. 

Conclusion

Once you’ve decided to build a smart contract, the first step is to choose the kind of token that works best for you. After making up your mind about fungible or nonfungible tokens, you can either go for ERC-20 or ERC-777 or build a popular NFT on ERC-721. If none interest you, there is always ERC-1155, where you can build a hybrid contract. 

Geniuses who proposed all these token standards had one thing in mind, making developers’ and business owners’ lives easier. We can pay homage to their genius by utilizing the token standards optimally. 

 

About The Author 

Author

Dr. Ravi Chamria is co-founder CEO of Zeeve Inc, an Enterprise Blockchain company. He has an experience of 18+ years in IT consulting spanning across Fintech, InsureTech, Supply Chain and eCommerce. He is an executive MBA from IIM, Lucknow and a prolific speaker on emerging technologies like Blockchain, IoT and AI/ML.

Passionate About: Blockchain, Supply Chain Management, Digital Lending, Digital Payments, AI/ML, IoT

Specialities: Strategic Management, Technology Innovation, Product Management


That the contents of third-party articles/blogs published here on the website, and the interpretation of all information in the article/blogs such as data, maps, numbers, opinions etc. displayed in the article/blogs and views or the opinions expressed within the content are solely of the author's; and do not reflect the opinions and beliefs of NASSCOM or its affiliates in any manner. NASSCOM does not take any liability w.r.t. content in any manner and will not be liable in any manner whatsoever for any kind of liability arising out of any act, error or omission. The contents of third-party article/blogs published, are provided solely as convenience; and the presence of these articles/blogs should not, under any circumstances, be considered as an endorsement of the contents by NASSCOM in any manner; and if you chose to access these articles/blogs , you do so at your own risk.


Zeeve is an enterprise-grade Blockchain Infrastructure Automation Platform. Join the growing list of clients that trust us with their Blockchain initiatives

© Copyright nasscom. All Rights Reserved.