This week we've discussed the pros & cons of the ERC-777 token standard. Today I'll cover things that developers should know about to build with ERC-777, and what the next steps are for this standard.
Speaking of, you'll need ERC1820 deployed to any chain that uses ERC777s.
This is already deployed to all major EVM chains, but if you're building in Hardhat, you should add this package to ensure that ERC1820 is available in your test chain.
A few little quirks of ERC777 that developers should know:
1. All 777s have 18 decimals, 777 uses the granularity() function instead. So if you're wrapping an ERC20 with less than 18 decimals, you need to do some quick conversion.
2. The transfer() function will send tokens to any address, but the send() function will fail if you're sending to a contract that doesn't support ERC777 hooks.
3. The mint function also will fail if you're sending to an unsupported contract.
4. As we've discussed many times, ERC777 transfers can introduce re-entrancy vulnerabilities. So make sure your transfers use the Check-Effects-Interactions pattern, and use re-entrancy guards if necessary.
Don't be the next LendFme!
That wraps up my developer tips!
So what are the next steps for ERC777?
The transition to Layer 2 is a big opportunity to finally embrace the many improvements ERC777 has to offer and make dapps easier for end users.
ERC777 has already been added to the Arbitrum bridge, and I've got an open PR to add it to Optimism.
If you've got thoughts about L2 bridges, feel free to take a look!
The most popular of these is permit(), which was originally created for Dai, and popularized in Uniswap V2.
Permit allows a the user to sign a message before their transaction, giving another contract permission to "pull" tokens. This signature gets included in the main tx.
This is a big improvement over the standard ERC-20 behavior.
First of all, users don't need to send an extra approve() transaction, saving them time and money.
Also, users typically don't give infinite approval, which avoids the recent security issues.
With the upcoming launch of optimistic rollups & some recent hacks, it's time to put some focus back on my favorite token standard!
Every day this week, I'll post a thread about ERC-777 and answer any questions about it
Today: an intro to ERC777 ⤵️
I like to think of ERC777 as ERC20 2.0
ERC-777 is a standard for fungible tokens, and it's fully backwards-compatible with ERC-20. It works with any existing wallet, but also adds new features.
For more details, check out this thread I made last year:
(1/10) The imBTC/Uniswap hack took advantage of the ERC777 standard, now I'm seeing many people saying that ERC777 is inherently bad or unsafe.
ERC20 is safer than ERC777 in the same way that Bitcoin is safer than Ethereum. It's safe because it's limited.
Here's some thoughts:
(2/12) First of all, for anyone that isn't familiar with ERC-777, you can think of it as ERC-20 2.0. It's a token standard that's backwards compatible with ERC-20, but adds some new features.
(3/12) The ERC-20 standard was written in 2015. It's very simple, which has helped it become so popular.
However, it's very "underpowered" for a system that's trying to create "programmable money". Many of Ethereum's UX problems come from limitations of the ERC-20 standard.