What is an ERC?
ERC stands for Ethereum Request for Comments and is a subcategory of Standard Track EIP (Ethereum Improvement Proposal) that focuses on improvements related to tokens and smart contracts on the Ethereum Blockchain. EIPs are proposals made by the Ethereum community to suggest improvements on the Ethereum Blockchain. Once the community agrees that a proposal is important, it will be accepted and implemented on the Ethereum Network. A proposed ERC has to follow a standardization process and have implementation to become a standard for Ethereum DApp developers.
Token Standards are a set of rules that developers need to follow to develop and deploy tokens on the Ethereum Blockchain. A Smart Contract is used to develop a token.
Why are Token standards Needed?
Before understanding why token standards are needed, let's delve into the difference between coins and tokens. Coins are cryptocurrencies native to a particular blockchain, and that's the reason they can't be used on other blockchains. In other words, you can't send Bitcoins while interacting with the Ethereum blockchain (although you can with the help of the ERC-20 standard, that's outside the scope of this blog; for more information, see WBTC). Tokens are digital assets defined by smart contracts and built on top of a particular blockchain. A token can be of various types depending on its use case like reward tokens, utility tokens, currency tokens, governance tokens, and security tokens. A single token can be supported by different blockchains, thus solving the above interoperability issue of coins. So, token standards are instructions on how a smart contract should be written to achieve the desired functionalities.
ERC-20 (Fungible Tokens)
ERC-20 are fungible tokens, meaning they are interchangeable. Suppose, you and I both have 10 Apple stocks. Are they the same? Yes, of course. They represent the same thing, have the same value, and are of the same type. That's ERC-20 for you! To create an ERC-20 you must implement these functions:
- totalSupply(): Returns the total supply of ERC-20 tokens.
- balanceOf(): Returns the total number of tokens in an address.
- transfer(): Enables the transfer of tokens from one wallet account to another.
- transferFrom(): Similar to transfer() but allows smart contracts to transfer tokens on the owner's behalf.
- approve(): Sets a limit on the number of tokens a user is allowed to spend.
- allowance(): Returns the total number of tokens a user is allowed to spend on the owner's behalf.
Other than the above-mentioned functions, optional functions that can improve the usability of ERC-20 tokens include:
- name(): returns the name of the token
- symbol(): returns the token symbol
- decimals(): returns the number of decimals the token uses.
Use cases of ERC-20
- Initial Coin Offerings (ICOs): ERC-20 tokens have been widely used for fundraising through ICOs. Companies can issue ERC20 tokens to attract investors.
- Payments: Businesses can create their own ERC-20 token and use it to transact in their ecosystem.
- Stablecoins: They are ERC-20 tokens designed to maintain a stable value, often pegged to a fiat currency such as the US dollar. They are used for hedging against price volatility in the cryptocurrency market and facilitating trading.
- Interoperability: ERC20 tokens transfer is designed to be compatible with any Ethereum wallet or exchange, making it easy for users to manage and trade them.
- Reward Systems: a dApp offering file storage services can reward users with ERC20 tokens for donating idle disk space.
Some popular ERC-20 tokens include Chainlink (LINK), Uniswap (UNI), Aave (AAVE), Wrapped Ether (WETH), etc.
ERC-721 (Non-Fungible Tokens)
ERC-721 are referred to as NFTs (Non-Fungible Tokens) which represent something unique. It can be an audio, image, video, or any other media file. Every NFT minted from a smart contract is associated with a unique value, named token ID.
The functions to implement while creating ERC-721 are:
- balanceOf(): Counts all NFTs assigned to an owner.
- ownerOf(): Finds the owner of an NFT.
- safeTransferFrom(): Transfers the ownership of an NFT from one address to another address, with parameters as address _from, address _to, uint256 _tokenId, bytes data.
- safeTransferFrom(): Transfers the ownership of an NFT from one address to another address with input parameters as address _from, address _to, uint256 _tokenId.
- transferFrom(): Transfers ownership of an NFT.
- approve: Reaffirms the approved address for an NFT.
- setApprovalForAll(): Enables or disables approval for a third party ("operator") to manage.
- getApproved: Gets the approved address for a single NFT.
- isApprovedForAll(): Queries if an address is an authorized operator for another address.
Potential Use cases
- Gaming: ERC-721 tokens can be used in blockchain-based games, where each in-game asset is unique and can be traded by players. Examples include Axie Infinity and Gods Unchained.
- Digital Art and Collectibles: NFTs have gained significant popularity in recent years and allow artists to tokenize their artwork and sell it as a unique digital collectible.
- Virtual Worlds: NFTs can be used to represent a piece of real estate and other assets in a virtual world like Decentraland and The Sandbox.
- Domain Names: Domain names can be tokenized as NFTs, enabling users to buy and sell web addresses on the blockchain. A few examples include the Ethereum Name Service (ENS) and Unstoppable Domains. Social platforms like Lens Protocol also use ERC-721 tokens for usernames on the protocol.
- Event Ticketing: ERC-721 tokens can be used to create unique tickets for events such as concerts, conferences, and sports matches thereby, reducing the risk of black marketing and enabling secure resale on the secondary market. This idea was recently implemented by Polygon to provide tickets for F1 races held in Monaco.
Some of the most popular NFT projects are Cryptokitties, Bored Ape Yacht Club (BAYC), Axie Infinity, and Decentraland.
ERC-777 is the token standard for fungible tokens (implemented over ERC-20), introduced to facilitate more complex token transactions and remove ambiguity around decimals, minting, and burning. It also introduced a function called hooks, which is called when tokens are sent to it which helps to reject/accept the incoming tokens, redirect the tokens to other addresses, and eliminate the need to use 'approve' and 'transferFrom' in two separate transactions, as a new function named 'send' is introduced, thus reducing transaction costs and much more. This helps ensure that no tokens are stuck inside any contract, as has happened in many cases. This standard is backward-compatible with ERC-20s, meaning you can work the same way as with ERC-20s while still exploiting its usability.
The functions to implement here are:
- name(): Returns the name of the token.
- symbol(): Returns the symbol of the token, usually a shorter version of the name.
- granularity(): Returns the smallest part of the token that is not divisible. This means all token operations (creation, movement, and destruction) must have amounts that are a multiple of this number.
- totalSupply(): Returns the amount of tokens in existence.
- balanceOf(): Returns the amount of tokens owned by an account.
- send(): Moves amount tokens from the caller’s account to the recipient. If send or receive hooks are registered for the caller and recipient, the corresponding functions will be called with data and empty operator data.
- burn(): Destroys the number of tokens from the caller’s account, reducing the total supply. If a send hook is registered for the caller, the corresponding function will be called with data and empty operator data.
- isOperatorFor(): Returns true if an account is an operator of tokenHolder. Operators can send and burn tokens on behalf of their owners. All accounts are their own operator.
- authorizeOperator(): Makes an account an operator of the caller.
- revokeOperator(): Revokes an account’s operator status for the caller.
- defaultOperators(): Returns the list of default operators. These accounts are operators for all token holders, even if the authorizeOperator() was never called on them.
- operatorSend(): Moves amount tokens from sender to recipient. The caller must be an operator of the sender. If send or receive hooks are registered for sender and recipient, the corresponding functions will be called with data and operatorData.
- operatorBurn(): Destroys the amount of tokens from the account, reducing the total supply. The caller must be an operator of the account. If a send hook is registered for the account, the corresponding function will be called with data and operatorData.
Benefits of using ERC-777
- These tokens enable complex token interactions. Token transfers can include additional data, enabling customization and integration of various actions and functionalities with each transaction.
- They can optimize gas usage and reduce transaction costs. This is especially beneficial during high network congestion, making transactions more cost-effective.
- Developers can customize these tokens to meet specific project requirements, like a mixer contract, for greater transaction confidentiality.
ERC-1155 is a multi-token standard that helps create both fungible and non-fungible tokens along with semi-fungible tokens (they have both fungible and non-fungible properties). It helps to reduce the number of transactions required to manage multiple tokens, resulting in lower transaction costs and more efficiency. It also introduced the concept of Batch Transfers, which helps send multiple tokens in a single transaction.
The functions you must implement in a contract inheriting ERC-1155 are:
- balanceOf(): Returns the number of tokens of a token type specified by an account.
- balanceOfBatch(): Batched version of balanceOf().
- setApprovalForAll(): Sets approval for an address to manage all of the caller's tokens.
- isApprovedForAll(): Returns the approval status of the specified address for a given owner.
- safeTransferFrom(): Transfers the amount of tokens of the specified token type from one address to another.
- safeBatchTransferFrom(): Batched version of safeTransferFrom().
- Real Estate and Property Management: A real estate asset can be represented as a unique NFT, while fungible tokens can be used to represent ownership shares in a larger real estate portfolio.
- Fractional Ownership: Assets, such as real estate or high-value collectibles, can be divided into smaller units represented by fungible tokens, enabling fractional ownership and investment opportunities.
- Gaming industry: A game can have unique as well as interchangeable assets like every user account or attributes attested to the user which is unique and can be used to represent an NFT while in-game purchases can be tokenized with ERC-20.
Projects working with ERC-1155
A few projects utilizing this token standard are Enjin, Opensea, The Sandbox, Horizon Games, and Decentraland.
ERC-4626 (Tokenized Vaults)
ERC-4626 extends ERC-20 and was introduced to optimize and integrate technical parameters of yield-bearing vaults. A vault is a smart contract that manages and stores crypto. Each vault has its own tokens, which it generates as a form of returns, which can be exchanged for tokens that were originally locked in the vault. For example, when you yield farm USDC on Compound, you will get cUSD. Vaults are better and more secure compared to traditional wallets, which is why DeFi protocols like Sushiswap, Aave, Compound, and others use them. The functions used here are:
- asset(): Returns the address of the underlying token used for the vault for accounting, depositing, and withdrawing.
- totalAssets(): Returns the total amount of underlying assets held by the vault.
- convertToShares(): Returns the amount of shares that would be exchanged by the vault for the amount of assets provided.
- convertToAssets(): Returns the amount of assets that would be exchanged by the vault for the amount of shares provided.
- maxDeposit(): Returns the maximum amount of underlying assets that can be deposited in a single deposit call by the receiver.
- previewDeposit(): Allows users to simulate the effects of their deposit at the current block.
- deposit(): Deposits assets of underlying tokens into the vault and grants ownership of shares to the receiver.
- maxMint(): Returns the maximum amount of shares that can be minted in a single mint call by the receiver.
- previewMint(): Allows users to simulate the effects of their mint at the current block.
- mint(): Mints exactly shares vault shares to the receiver by depositing assets of underlying tokens.
- redeem(): Redeems a specific number of shares from the owner and sends assets of underlying tokens from the vault to the receiver.
- previewRedeem(): Allows users to simulate the effects of their redemption at the current block.
- maxRedeem(): Returns the maximum amount of shares that can be redeemed from the owner's balance through a redeem call.
- withdraw(): Burns shares from the owner and sends exact assets tokens from the vault to the receiver.
- previewWithdraw(): Allows users to simulate the effects of their withdrawal at the current block.
- maxWithdraw(): Returns the maximum amount of underlying assets that can be withdrawn from the owner's balance with a single withdraw call.
Why do we need ERC-4626?
The problems a DeFi developer faces regarding yield-bearing tokens involve integrating tokens of different protocols. Consider a situation where you are building a DApp that supports tokens from multiple protocols; you'll have to go through every single protocol's yield accrual model and implement it separately, and that's a tiring task! That's why ERC-4626 was introduced. Since there is a token standard for developing vaults, it makes protocol integration easier and more secure.
Projects building on ERC-4626
Yearn Finance, Balancer, Frax Finance, and Maple Finance
These are a few popular ERC standards that drive the development of the Ethereum Ecosystem by providing a set of guidelines for developers to build native tokens, DeFi projects, NFTs, etc while ensuring compatibility and security. There are more than 50 ERC standards that cover a wide range of use cases and they continue to evolve as the new use cases arrive.
For Press Releases, project updates, and guest posts publishing with us, email to firstname.lastname@example.org.
Subscribe to EtherWorld YouTube channel for ELI5 content.
Share if you like the content. Donate at avarch.eth or Gitcoin
If you've something to share with the blockchain community, join us on Discord!