Before diving deep into ‘what is ERC777’, one must understand ‘what is ERC20’!
What is the need for ERC20?
It wouldn’t be wrong to say that ERC20 protocol has been the launchpad upon which the rocket of Blockchain economy was built and set into the orbit. A large number of innovations—in the space of DApps—came into existence, because of the advent of a standard protocol like ERC20.
During the pre-ERC20 era, the Ethereum developer community was struggling in the absence of any standard protocol to abide by, while developing their distributed application.
The ERC20 standard protocol laid out a set commands or specification standards that every token on the Ethereum platform must adhere to.
What is the need for ERC777?
To a great extent, ERC20 standard did come in as a life saver for the Ethereum developer community. But similar to any invention that needs time to evolve, ERC20 was also far from being perfect.
Below are some of the inherent drawbacks of ERC20 protocol:
1- Every day, tokens worth thousands of dollars get stuck permanently, once sent to accounts with no withdrawal feature or to contracts that do not support them at all. On ERC20, there isn’t a validation in place—prior to sending these tokens out to the destination contract/address—to understand if the tokens are compatible with the destination address or not. In majority of these cases, these tokens can not be retrieved back and get lost for ever.
2- ERC20 protocol requires 2 transactions, in order to send tokens to a smart contract. As we all know, greater the number transactions, higher would be the Gas requirement. And higher the Gas requirement, higher the cost associated with the ‘transfer of tokens’. The need for 2 transactions arises because of the two functions that are involved in the token transfer (to a smart contract), i.e.
– function approve(address _spender, uint _value) returns (bool success);
– function transferFrom(address _from, address _to, uint _value) returns (bool success);
ERC820 Explained
ERC777 token protocol builds upon the legacy of ERC20 and tries to plug the gaps that the later has, with the help of ERC820.
Okey.. So before you exclaim “WHAT!”, let me introduce you to ERC820 standard.
And hold on.. Do not get confused here! Yes, it does seem like another variant of the ERC token standards family, but interestingly it is not.
Actually, ERC820 is a ‘Registry Standard’ smart contract and not a ‘Token Standard’…
So as part of ERC820 smart contract, a registry is maintained, which is open for everyone to make use of. This registry holds “what address supports what interface” (standard).
ERC777 token standard makes use of the ERC820 registry to check if the smart contract address—to which the tokens are being sent—supports the token or not.
This register helps in reducing the chances of sending tokens to a non-supportive smart contract, which in-turn eliminates the possibility of unusable/lost or locked tokens.
Also, since ERC777 uses ERC820 registry, before sending tokens to smart contracts, a single transaction is good enough. A need for 2 transactions was paramount in ERC20, if tokens were being sent to a smart contract.
What is ERC777? [A New Advanced Token Standard for Ethereum]
With enough basics in our kitty, lets try to understand ERC777 a little in detail:
The ERC777 token standard has been built and proposed by Jordi Baylina, Jacques Dafflon & Thomas Shababi.
The Ethereum Improvement Proposal for ERC777 is currently open community feedback and scrutiny. In all likelihood, it is expected to get finalized by August of 2018 and there after its success or failure would totally rely on the kind of support and adoption it gets from the developer community.
Below is the proposed specification of ERC777 (Contract):
interface ERC777Token {
function name() public constant returns (string);
function symbol() public constant returns (string);
function totalSupply() public constant returns (uint256);
function granularity() public constant returns (uint256);
function balanceOf(address owner) public constant returns (uint256);
function send(address to, uint256 amount) public;
function send(address to, uint256 amount, bytes userData) public;
function authorizeOperator(address operator) public;
function revokeOperator(address operator) public;
function isOperatorFor(address operator, address tokenHolder) public constant returns (bool);
function operatorSend(address from, address to, uint256 amount, bytes userData, bytes operatorData) public;
event Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes userData, bytes operatorData);
event Minted(address indexed operator, address indexed to, uint256 amount, bytes operatorData);
event Burned(address indexed operator, address indexed from, uint256 amount, bytes userData, bytes operatorData);
event AuthorizedOperator(address indexed operator, address indexed tokenHolder);
event RevokedOperator(address indexed operator, address indexed tokenHolder);
}
Key Advantages of ERC777 And Differences between ERC20 and ERC777
– Since the foundation of ERC777 is built on the principles of ERC20, this new standard is fully backwards compatible with the former and tries to improves it.
– ERC777 uses the send() function, instead of the transfer() function of ERC20. This reduces the need of transactions from 2 to 1, in case of a token transfer to a smart contract.
– ERC777 boasts an upper hand on ERC20, since the new standard allows for “Hooks”. These “Hooks” are nothing but a set of functions that can be called upon, during a token transfer. This can enable—but not limited to—a notification, to be sent to the sender or the receiver, before or after the transaction.
– With ERC777, a token holder can set an Operator (which could either be another smart contract or a regular address) that has authority to transfer or burn tokens on behalf of another token holder. This feature is not available on ERC20 standard.
Only time will tell whether ERC777 will receive the same kind of support that ERC20 has, or it will also get lost in the crowd as just another token standard (like ERC223).