question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deprecate ERC777 implementation

See original GitHub issue

🧐 Motivation

There is an opinion that ERC777 is over-engineered and is a bad practice to follow. Moreover it introduces bad abstractions to rely on and requires very important checks to be implemented by every integrator.

Let’s switch to EIP2612 (Permit) to deprecate dangerous infinite approve behavior and make it mainstream ASAP: https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC20/extensions/draft-ERC20Permit.sol

šŸ“ Details

Do we need to collect list of issues? Starting here:

  1. Whole idea of avoiding spam tokens by having hook function is wrong. It is not possible to protect from spam tokens because developers of these tokens will always modify their tokens to allow spamming – just ignore them.

  2. Token fallback concept is wrong because the callback is being called from token smart contract and there is no way to verify who was the original msg.sender. There are so many possible ways to abuse ERC777Receiver. The only way to solve it I see – work with whitelisted tokens only – DeFi deserves better approach. Imagine you have DEX and wanna deposit token and do custom action (swap):

    function tokensReceived(
        address operator,
        address from,
        address to,
        uint256 amount,
        bytes calldata userData,
        bytes calldata operatorData
    ) external override {
        address token = msg.sender;
        balances[token][operator] += amount;
        _performSwap(operator, operatorData); // <- `operator` is not trustworthy, due `msg.sender` can be malicious smart contract
    }
    
    function _performSwap(address user, bytes memory data) internal {
        // ...
    }
    

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:14
  • Comments:50 (34 by maintainers)

github_iconTop GitHub Comments

6reactions
frangiocommented, Jun 1, 2021

We don’t think it should be OpenZeppelin Contracts making the decision to deprecate the ERC.

We’re happy to include comments in our documentation about the downsides and alternatives.

For actual deprecation, we’re happy to host the discussion here, but ultimately we feel that a deprecation requires a more ecosystem-wide consensus.

5reactions
Amxxcommented, Mar 29, 2021

Hello @k06a, As a developper working with ERC777 during hackathon, I can only agree that this standard creates a lot of frustration … and can result in very gas-extensive transactions.

However, deprecating contract breaks backward compatibility. This is not something we would consider doing during a ā€œminorā€ release. The latest major release was v4.0, less then a month ago. Thus, we wouldn’t move with anything like that before a while.

Still, I’d love to build a case for/against ERC777 (and other contract that might not be relevant). This will help us taking decision whenever we fell like moving to the next major version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Are ERC777 tokens safe to deploy to the mainnet? - Security
I recently came across the ERC777 standard and I saw its huge potential. ... Proposal to deprecate ERC777 implementation.
Read more >
Lesser-Known ERC Tokenization Standards On Ethereum
A brief exploration of Ethereum token standards like ERC-223, ERC-777, ... improve upon existing standards by implementing useful new features and designingĀ ...
Read more >
Correct usage of granularity in ERC777
I think that you are referring to the Open Zeppelin implementation of the ERC777 contract. As you say, it doesn't check for granularity...
Read more >
David Mihal.eth on Twitter: "(7/12) There's over $100,000 ...
(1/10) The imBTC/Uniswap hack took advantage of the ERC777 standard, ... (8/12) ERC777 + contract wallets would remove the issue of "spam tokens",Ā ......
Read more >
EIP-777: Token Standard - Ethereum Improvement Proposals
The token contract MUST implement the above interface. ... If the contract has a switch to enable or disable ERC777 functions,Ā ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found