Ethereum was the first blockchain network to introduce smart contracts in its platform. These are programs that are built to execute themselves by using predefined conditions. The most common analogy is the vending machine. If you put enough money in them and push the right button, a coke will come out. This process does not require any human intervention and is deterministic, meaning that the same input will always result in the same output. That is how a smart contract works, it is coded so that it can produce a result depending on certain variables. These programs can be used to build all kinds of applications.
But what is the big deal? Apps and vending machines existed before Ethereum.
That’s a good point, the difference is that Ethereum provides an environment that allows these apps to execute in a decentralized and censorship-resistant manner. Instead of having one single server running these apps, the data is distributed between thousands of nodes. No person, company, or government is in control. To archive this, Ethereum makes use of blockchain technology. A blockchain is a database that is stored in multiple places at the same time. By combining blockchain technology and smart contracts, Ethereum has managed to create an alternative financial system that is transparent, decentralized, borderless, and accessible by anyone with an internet connection. Unfortunately, it doesn’t come without its drawbacks.
What is Ethereum’s biggest hurdle right now?
Arguably, the biggest problem with Ethereum right now is gas fees. Ethereum produces 1 block every 12 seconds, that block has a limit on how much data it can hold. If a lot of people want to transact at the same time, they will have to pay a higher price for their transaction to be prioritized over the other ones. When demand for block space rises, gas fees rise. That is why blockchain networks are difficult to scale. During high congestion times, doing a simple transfer on the Ethereum blockchain can cost more than 100 dollars.
The trick is to get that scalability, without sacrificing security and decentralization. One solution could be to just make the blocks bigger, which would create space for more transactions. Nevertheless, doing so will make the blockchain heavy. This means that only powerful computers will be able to store and update all this data. Raising requirements for running a node means the number of nodes will go down. Fewer nodes equal less decentralization and poor security.
What’s the solution? Are blockchains unable to scale properly?
Fortunately, there is another solution that could make blockchain networks secure, scalable, and decentralized. These are layer 2(L2) protocols based on rollups. They work by aggregating a bunch of transactions off-chain and then submitting a proof of those to the main chain. L2 protocols can process transactions and keep a record of them. After a set amount of time, they take all those transactions, compress them, and present that to layer 1. They effectively multiplied by a couple of orders of magnitude the amount of data that a block can hold. Of course, this has a dramatic effect on gas fees. You can check the current cost to send and swap tokens on all the main ETH L2s here. To have a sense of the L2 ecosystem, its size, and its characteristics you can check out this site.
There are mainly 2 kinds of layer 2 solutions, they differ in the way they compress and validate transactions. The most prominent L2 networks use either Optimistic Rollups or Zero-Knowledge Rollups. Let’s discuss how they work.
Optimistic rollups initially assume every transaction is valid, although they have “watchtowers” who are constantly searching for inconsistencies. If they happen to spot a dubious transaction, they can submit a fraud-proof to the network. When that happens, the said transaction is presented to the main network for it to be validated. If it turns out to be fraudulent, the party that presented the transaction will be punished. The good thing about optimistic rollups is that only 1 honest watchtower is needed for it to work.
The main advantage of optimistic rollups is they are compatible with the Ethereum Virtual Machine(EVM). This means projects can migrate from the Ethereum mainnet to the L2s with just one click, with no need to alter the code. Nevertheless, due to the fraud-proof system, withdrawals from the L2 to the mainnet can take up to 1 week. This is to give proper time to the watchtowers to do their job. The biggest optimistic rollup L2s are Optimism and Arbitrum.
Zero-Knowledge(ZK) rollups are a whole different beast. They leverage a complex cryptography system called Zero-Knowledge Proof that allows anyone to prove a statement is true without actually revealing it. In that way, this kind of L2s will generate a proof of all the transactions using ZK technology and submit that to layer 1.
In this way, they solve the withdrawal waiting time of optimistic rollups. Nevertheless, due to the complexity of the ZK system, it is difficult to develop an EVM-compatible ZK rollup. We currently have functioning ZK L2s but they are limited to swaps and transfers, they can’t handle more sophisticated smart contracts. Some examples are Loopring and ZkSync. There are several projects working on solving this issue so we could see an EVM compatible ZK rollup soon.
Getting our hands dirty on Ethereum Layer 2 solutions
Now that we are aware of the technology behind it, we can start interacting with these chains. Layer 2 protocols work hard to have a similar or better user experience than Ethereum mainnet, so if you are a DeFi user this should be a walk in the park. If you are on the beginner side you shouldn’t worry either, it’s easier than it seems.
If you already have ETH in a wallet then you can send it directly to something like Metamask but there may be a cheaper option to get it there (covered below). Once you have an L2 protocol in your Metamask wallet you can start to interact with DeFi projects. Let’s break down some situations below:
- Make sure your Metamask browser wallet is setup with L2 protocol networks
You’ll need to add networks to your wallet for whichever L2 protocol you want to use. Let’s say for example it’s Polygon (MATIC). You would simply go to the settings in Metamask and add a network.
Above is the example of what would be added, this would be done for each L2 protocol you want to add (simply google the proper details for whichever one you want to add).
2. If you already have ETH on Metamask
To avoid higher bridge fees to convert ETH to another L2 you could use hop protocol because it gives us more options in terms of L2 protocols to bridge to. It currently supports ETH mainnet, Optimism, Arbitrum, Gnosis, and Polygon. By using hop, we can send ETH to Arbitrum without even going through the mainnet and paying high gas fees. Apart from that, as hop protocol doesn’t have a token yet there is a rumor that it will soon make an airdrop to its users. It is not confirmed but it’s still worth the try!
Here is a blog post detailing a bit more on how the hop protocol works and using the bridge.
- If you have ETH on a centralized exchange that allows ETH withdrawals through L2 protocols like Polygon (from exchange to browser wallet)
With higher gas fees on ETH transfers if you are using something like crypto.com you can select another network to withdraw (BSC, Arbitrum, Polygon, AVAXC, Cronos) which will be cheaper than sending to MetaMask on the ETH mainnet than using a bridge to another L2 protocol.
- Once you have an L2 protocol in your MetaMask (and bridged ETH) you can interact with DeFi protocols on whichever L2 protocol you choose. Once on the DeFi website, you’ll simply connect your wallet.
For example, some of the most popular protocols on Arbitrum are:
- Beefy Finance
In essence, what layer 2 protocols do is alleviate the pressure of layer 1 by processing transactions off-chain but doing the final validation on the L1. It’s a good way to obtain scalability without sacrificing decentralization and security. The Ethereum layer 2 ecosystem is still in the early stages but it’s growing every day. There seems to be an agreement in the crypto environment favoring rollups as the best way to help blockchains scale. As in every industry, early adopters are always well rewarded in the long run. Getting involved and interacting with this ecosystem is a low-risk, high-reward bet that could pay off in the future.
Written By: Ramiro Menne – MSW Contributor