INTRODUCTION TO TOKEN STANDARDS FOR ETHEREUM : PART 2 — ERC20 and ERC721

Deepti Nagarkar
Coinmonks
Published in
3 min readNov 10, 2022

--

Photo by Traxer on Unsplash

This is the second of a 4 part series on token standards. Here I am going to introduce token standards for fungible and non fungible tokens (NFTs).

For basics of token standards, please refer to the first post in this series.

Token Standards for Fungible Tokens : ERC20

Photo by Dan Dennis on Unsplash

The ERC-20 introduces a standard for Fungible Tokens. This is the most widely used standard by far in the Blockchain space.

What is a fungible token ?

A fungible token is one in which each Token be exactly the same (in type and value) as another Token. For example, an ERC-20 Token acts just like the ETH, meaning that 1 Token is and will always be equal to all the other Tokens.

ERC 20 Token Standard

The ERC-20 introduces a standard for Fungible Tokens

  • A standard interface allows any tokens on Ethereum to be re-used by other applications: from wallets to decentralized exchanges.
  • Many ERC20-compliant tokens deployed on the Ethereum network
  • It’s a fungible token standard.
  • Issuing new tokens using ERC 20 standard is easy.
  • This is the most commonly used standard to date. Many of the cryptocurrencies in existence on the Ethereum blockchain are ERC-20 tokens.
  • Every digital wallet that accepts ether also accepts ERC-20-compliant tokens.

Functions & Events in the ERC 20 Token Standard

The fundamental code functions for ERC-20 token implementation are as follows:

  • transfer tokens from one account to another
  • get the current token balance of an account
  • get the total supply of the token available on the network
  • approve whether an amount of token from an account can be spent by a third-party account

These code methods are crucial for user/token implementation, as they determine the quantity of tokens in circulation, store and return balances, request and approve transfer and withdrawal requests, and agree to automated transfers, among other things.

ERC-20 defines the following events :

  • Transfer event on token transfer
  • Approval event on account approval

Specification for ERC 20

Functions :

  • balanceOf
  • totalSupply
  • transfer
  • transferFrom
  • approve
  • allowance
  • name
  • symbol
  • decimals

Events :

  • Transfer
  • Approval

Token Standards for Non Fungible Tokens : ERC721

The ERC-721 introduces a standard for Non Fungible Tokens.

Photo by Andrey Metelev on Unsplash

What are Non Fungible Tokens (NFTs) ?

NFTs or non-fungible tokens are digital tokens that are unique and cannot be substituted or divided by another token. NFTs can represent ownership over digital or physical assets.

ERC 721 Token Standard

The ERC-721 introduces a standard for Non Fungible Tokens. A separate standard is required for NFTs as —

  • ERC 20 is insufficient for tracking NFTs because each asset is distinct (non-fungible)
  • Each asset must have its ownership individually and atomically tracked.
  • Defines the implementation of a standard API for NFTs within smart contracts
  • Provides basic functionality to track and transfer NFTs.

Specification for ERC 721

Functions :

  • balanceOf
  • ownerOf
  • safeTransferFrom
  • transferFrom
  • approve
  • setApprovalForAll
  • getApproved
  • isApprovedForAll

Events :-

  • Transfer
  • Approval
  • ApprovalForAll

A wallet/broker/auction application MUST implement the wallet interface to accept NFTs.

ERC721TokenReceiver

Functions :

onERC721Received

Key Differences Between ERC 20 and ERC 721 Tokens

To summarize, the differences between ERC 20 and ERC 721 are as below —

Difference between ERC 20 and ERC 721

In the next article, I will introduce extensions to the two standards that are essential for the ERC 20 and ERC 721 implementation and also enhance the functionality.

New to trading? Try crypto trading bots or copy trading

--

--