SHIVAJI(8)
An Ethereum Request for Comments (ERC) is a standard, a document that programmers use to write smart contracts on Ethereum Blockchain. They describe rules in these documents that Ethereum-based tokens must comply with.
There are many Ethereum standards. Below 2 are the most well-known and popular:
Before we dive into these, let's first understand what exactly a token is.
A token refers to a digital asset or unit of value that is created and managed on a blockchain platform. Tokens can represent various types of assets, rights, or utilities.
In ethereum, tokens can represent virtually anything. Reputation points in an online platform, skills of a character in a game, financial assets like a share in a company a fiat currency like USD, an ounce of gold, and more.
The ERC-20 introduces a standard for Fungible Tokens, in other words, they have a property that makes 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. (e.g. 1 NPR coin will always be equal to any other 1 NPR coin)
ERC-20 provides below functionalities:
If a Smart Contract implements the following methods and events it can be called an ERC-20 Token Contract and, once deployed, it will be responsible to keep track of the created tokens on Ethereum.
function name() public view returns (string)
function symbol() public view returns (string)
function decimals() public view returns (uint8)
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)
function approve(address _spender, uint256 _value) public returns (bool success)
function allowance(address _owner, address _spender) public view returns (uint256 remaining)
event Transfer(address indexed _from, address indexed _to, uint256 _value)
event Approval(address indexed _owner, address indexed _spender, uint256 _value)
Let's understand the purpose of each of the methods.
Let's understand the purpose of each of the events.
There are already many implementations of ERC-20 compliant tokens in Ethereum network. Different implementation by different teams comes with different trade-offs; including gas saving to improved security.
Please refer to this for more detailed explanation.
ERC-721 ntroduces a standard for Non Fungible Tokens (NFTs), in other words, this type of Token is unique and can have different value than another Token from the same Smart Contract.
ERC-721 provides functionalities similar to ERC-20 tokens.
The uniqueness of each ERC721 token is a key characteristic. There are one and only one of these ERC721 Tokens when you create an ERC721 token. These tokens, as NFTs, are spreading the idea and use of new assets to Ethereum.
If a Smart Contract implements the following methods and events it can be called an ERC-721 Token Contract.
function balanceOf(address _owner) external view returns (uint256);
function ownerOf(uint256 _tokenId) external view returns (address);
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
function approve(address _approved, uint256 _tokenId) external payable;
function setApprovalForAll(address _operator, bool _approved) external;
function getApproved(uint256 _tokenId) external view returns (address);
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
Let's understand the purpose of each of the methods.
Please refer to this for detailed explanation.