What is erc777 token and what is the difference between erc777 token and erc20 token

Time:2021-1-6

Erc777 token introduction

Different from erc20 standard, which is widely used in Ethereum ecosystem, erc777 standard is usually called the newborn in the city. A child with great potential. Some even claim that erc777 is a valid successor to erc20. Erc777 standard specification is described in detail in eip777 (Ethereum improvement proposal document).

In this blog post, we will explore whether these bold claims are reasonable, and give an in-depth overview of the advantages (and some disadvantages) of erc777 compared with erc20 standard.

What erc20 problems does erc777 solve?

Suppose you want to allow a third party account (or contract) to use your token. The most common requirement is to use the smart contract of the decentralized exchange to issue money with one key.

The first step in this process is to call erc20 through the smart contractapproveMethod function to approve the transfer account and set the limit of funds to which they are entitled. In addition to trusting third parties with your money, you also need to make sure that the spending limit is always sufficient to meet the required transactions.

Erc777 operators

Erc777 standard solves the above problems by introducing the concept of operator. As always, operators are accounts with permissions to perform specific tasks. Under the erc777 standard, there are two types of operators:

  1. Default operator
  2. Designated operators

A designated operator is an address that is allowed to send and destroy tokens on behalf of another address. A default operator is the address that allows tokens to be sent and destroyed on behalf of all token holders.

Any erc777 token holder address can be calledauthorizeOperatorThe method function grants permission to a specified operator. Similarly, any erc777 token holder can call therevokeOperatorMethod function removes the authorization of the operator address (including the default operator).

In the erc777 implementation of one click coin issuingThe default operator is the address used to deploy the token.

Another small (and less obvious) benefit of taking advantage of carrier functionality is that users no longer need to worry about transaction fees and gas prices. It can now be delegated to operators.

Erc777 hook – an additional security mechanism

Erc777 hook is a code segment bound (hook) with the account of the transferor and the receiver. In essence, they are examples of smart contracts:

  1. IERC777SenderInterface has a functiontokensToSend
  2. IERC777RecipientInterface has a functiontokensReceived

The address instances of the smart contracts of the two interfaces are stored in the erc1820 registry and paired with their “hook” addresses.

If the transfer address has a matchingIERC777SenderInstance, it is called before the transaction is executedtokensToSendFunction. If no matching instance is found, the transfer transaction will proceed as usual.

If the receive address has a matchingIERC777RecipientInstance, it is called after the transaction is executedtokensReceivedFunction. If the receiving address is normal and no matching instance is found, the transfer will proceed as usual. However, if the recipient address is a contract address and no matching instance is found,The transfer transaction will be cancelled

In the figure below, you can see the process of “hook” transfer call.

What is erc777 token and what is the difference between erc777 token and erc20 token

Therefore, the introduction of hook enables us to enhance the transfer function of erc777 token, even after the token is deployed. It also provides the possibility to cancel a transaction if certain conditions are not met.

Disadvantages of erc777

The new features of erc777 do bring some disadvantages:

  1. Due to its use of pegging, transfer transaction costs are slightly higher
  2. Holding tokens requires more careful scrutiny because you have to trust the operator of your choice