ghConnectHub

ERC standards for smart contract develoment

analyticagh |
Education & Learning
To allow the creation of smart contracts on the Ethereum Virtual Machine, developers advocated for a standard for tokens that will allow anyone to adopt in the creation of tokens to enhance code reuse and prevent different variants of Ethereum tokens. The developers having submitted their Ethereum Improvement Proposal (EIP) which describes the functionality along with its specific protocols and standards. A committee then will is formed to review, approve, amend, and finalize the proposal, then, it becomes an ERC.

Most are familiar with ERC20, perhaps you may even own a few. But did you know there are other improved standards besides besides ERC20? Lets find out from this post.

ERC20

These specifications became known as the ERC- 20(Ethereum Request for Comments 20). ERC20 has become the standard that has enabled seamless interaction and development of tokens with smart contracts. Other Wallet offering services that hold digital tokens also adopt this framework in their wallet applications to enable them to receive, exchange, store and send tokens. Tokens developed using the ERC20 standard is also known as Fungible Tokens.

ERC20 defines the following set of functions when using smart contracts balanceOf , totalSupply , transfer , transferFrom , approve , and allowance . There are also a few optional functions like the token name, symbol, and the number of decimal places with which a token should have.

TotalSupply(): Using this function, it allows for the computation of the total amount of the token that is in circulation

BalanceOf(): This function permits the storage and return of balances of a provided address. The function accepts an address as a parameter.

Approve(): With this function, the owner of the contract approves, the given address to withdraw instances of the token from the owner’s address.

Transfer(): The transfer function lets the owner of the contract to send a set amount of a token to another person or address, this is normally done every time an owner of a token wants to send an amount to another.

TransferFrom(): This function when implemented in a smart contract, it allows a user to automate the transfer process to send a given amount of the token on behalf of the owner without doing it manually.
the optional functions are descriptive of their purpose. thus token symbol, token name and token decimal

ERC-721

ERC-721 ushered in a new standard for Non Fungible Tokens(NFT). NFTs are unique tokens that have different value than another similar token of the same smart contract. Differences exist as a result of rarity, expertise of creator or age of the item. These tokens are useful to platforms that offer collectible items like in basketball, lottery items, sports and art. This standard is much more complex that the defacto ERC20 and it can represent ownership of NFT.

ERC777

Just like the ERC20, ERC777 is a standard for fungible tokens, its focus is extending the functionalities to allow for more interactions when trading tokens.

The standard has multiple enhancements, one of such is minting and burning tokens with events, among others, prominent being the receive hooks function. This is simply a function in a contract that is called when tokens are sent to it, meaning accounts and contracts can respond to receiving tokens.

This has opened up interesting use cases, including easy transfers using tokens Approving and transferFrom in two separate transactions no longer a norm, rejecting receipt of tokens (thus reverting on the hook call when a condition is met without losing tokens), redirecting or splitting the received tokens to other addresses when received. All these changes come with the ERC-777 standard.

 

ERC1155

ERC1155, being a new token standard, it brings the best from earlier standards to create a much more complete and gas-efficient token contract.

ERC1155 draws ideas from all of ERC20, and ERC777.

The distinctive feature of ERC1155 is that it uses a single smart contract to represent multiple tokens at once. Thus both fungible and NFTs, in ERC1155 accounts have a distinct balance for each token contained, and non-fungible tokens are implemented by simply minting a single one of them.

This approach enables massive gas savings for smart contract projects that require interaction with multiple tokens. No need to deploy a new contract for each token type, a single ERC1155 contract can hold the smart contract state, reducing deployment costs and complexity.

Because all state is held in a single contract, Using batch operations, multiple tokens be it fungible and non fungible can reside within a single transaction very efficiently. The standard provides two functions, balanceOfBatch and safeBatchTransferFrom, that make querying multiple balances and transferring multiple tokens simpler and less gas-intensive.

How do I create a smart Contract?

Smart contract involved coding business logic on the blockchain. To start with its development one must have knowledge in programming solidity, other secondary knowledge areas may become necessary as one advances.

Conclusion

With the advancement in the development of Ethereum standards, most people still widely know and use the defacto ERC-20 standard. As time goes on, Improvements might be made if there is a need for further proposals.