Today, we have the great pleasure of sharing a piece by our guest writer Reuben Noronha.
Reuben wrote this amazing article on Layer 2 especially for the readers of Crypto Explained, so if you appreciate the effort, make sure to like this post! You can find him on twitter @NoronhaReuben!
If you’ve ever done a transaction on Ethereum in the last few years, you’ve probably encountered high gas prices. There’s this great NFT you want to buy and it only costs $5 but the damn gas price is $50. Gas fees can even go up to a couple of hundreds of dollars.
This is one of the big challenges with Ethereum which restricts people from using the network. It’s called the scaling challenge and this is where Layer 2 (L2) solutions play a role.
However, before we jump into understanding what L2s are and how they solve this, let’s first understand the problem of high gas fees…
What is gas fee?
When you do a transaction on any Ethereum application you pay a transaction fee.
This is like the fee you pay to transfer money from one bank to another or when you’re sending money abroad. The fee is paid to the network to validate the transaction and ensure the security of the network.
On Ethereum, this transactions fee is referred to as “gas fee”.
But why do gas fees go up?
This is the same as surge pricing on any ride-hailing app. When there’s a lot of demand, prices go up.
In the case of Ethereum, there is a limit on the number of transactions that can be processed on every block and during times of high demand, like an NFT drop, the demand on the network goes up which pushes up the gas price.
Over the last few years, there have been hundreds of new applications built on Ethereum ranging from Defi to NFTs and as these applications compete for bandwidth, gas prices have been steadily rising.
Side note: Rising gas fees is one of the big reasons why we’ve seen the emergence of new “Ethereum-killers” like Solana, which offer much faster transactions and lower prices. They can do so by compromising on decentralization to some degree. We’ll skip going into the details for now, but the rise of the new blockchain with billions of market cap only goes to shows that the gas problem is a big one
So to summarize, as more and more people use Ethereum, the transaction fees have been rising, making it harder for people to afford. This is not ideal and will prevent Ethereum from scaling.
Now that we understand the gas fee problem, let’s dive in to understand what L2s are and how they can solve this problem.
So what is Layer 2?
Layer 2 is a collective term for solutions designed to help scale applications by moving some of the transaction “off-chain” while taking advantage of the security of the main blockchain.
Think of these L2s as separate blockchains but they are all rooted in Ethereum - like branches of a tree. If Ethereum is the trunk and root, L2s are the branches where the birds (users) hang out and build nests (applications) - quite the analogy eh?
What is important about L2 is that they take advantage of the security of the main blockchain.
This is one of the biggest differences between an L2 on Ethereum and an alternative L1 blockchain like Solana.
Let me explain this using another analogy, which I borrowed from the Bankless podcast.
If New York City was a blockchain, then the price of land in New York would be the gas fee. Over time, the price of land has gone up as increasingly people move to live in New York (the best city in the world they say). To make living in the city more accessible, humans invented this revolutionary technology called skyscrapers so that more people could live on the same piece of land. You can think of L2s as the skyscrapers.
Now it’s important to note that the residents of skyscrapers in NYC still rely on the New York Police Department to keep maintain law and order. Each skyscraper doesn’t go set up its own police force. This is one of the main benefits of L2 solutions. This is not the case with other L1 blockchains like Solana, where they need to invest resources towards securing the blockchain. This allows L2s to reduce the cost of transactions without compromising on robust decentralized security.
How does Layer 2 work?
There are different kinds of L2 solutions with different mechanisms. But in essence, what they all do is move transactions off-chain.
What that means is that instead of everything happening on the main blockchain (Ethereum), most of these transactions are recorded off-chain (on Layer 2 chains) and only the “final” or “ summary” transaction is stored on the main blockchain.
Let’s look at a simple example.
When you go to the bar, you get yourself a nice Gin and Tonic and swipe your card. You then order a second one, and pay a second time. You enjoy the vibe of the place and get another drink, a Martini this time, and pay for the third time. You’ve made three separate transactions and the staff would have had to swipe your card three times.
Alternatively, you could open a tab, buy a bunch of drinks and at the end of the night, you close your tab and pay the bill. In this case, you’re making one single transaction and this saves a ton of time and transaction fees!
The tab here is the L2, which keeps track of all the transactions “off-chain”, so when you swipe your card, it’s just one transaction in your bank statement (on-chain).
Different kinds of L2
Now that you have a broad understanding of how L2s works, let’s spend some time talking about the different kinds of layer 2 solutions. We will briefly touch upon the 4 main types, but we won’t get into the details in this article.
State Channels: State channels use smart contracts to enable participants to transact quickly and freely off-chain, then settle finality with Mainnet. There’s no blockchain involved but simple contracts with a set of rules.
Side-Chains: A sidechain is an independent blockchain that runs in parallel to the main chain. These are compatible with Ethereum and run under their own rules and mechanisms. Polygon is one of the biggest side chains on Ethereum
Rollups: Rollups perform transactions off-chain and then the transaction data is posted to Layer 1 where consensus is reached. As transaction data is included in Layer 1 blocks, this allows rollups to be secured by native Ethereum security. Optimism, Arbitrum, StarkWare, and Zksync are different kinds of rollups
Plasma: These are similar to Rollups but the biggest difference is that they do not post all the transaction data back to the main chain.
Now, why would you choose one over the other will require us to go into more technical details, so we’ll cover that in a future essay.
Risks with Layer 2s
Just like everything else in crypto, there are a few risks associated with L2s. Given this is still relatively new technology, it’s important to be aware of the risk and where things can go wrong
Bridging Risk: When you’re moving your funds from the main chain to the L2, you use a “bridge” and these bridges are highly susceptible to getting hacked. One of the biggest hacks in 2022 involved a bridge between Solana and Ethereum
L2 Risk: Given that most of the L2s are new, their code may have bugs and vulnerabilities which can lead to assets getting stolen. Even though L2s benefit a lot from the security of the main net, there is still a chance that the applications on L2 can get hacked and users lose funds.
What does this mean for me?
Great question! Now that you understand what L2s are and how they work, the benefit of using them is lower transaction fees!
Many web3 applications are now available on L2s. Below is an example of Uniswap, which is one of the biggest decentralized exchanges. You can choose which network you want to use it on. On Ethereum, a simple trade could cost you $20-30 but the same trade on the L2 chains like Polygon, Arbitrum, or Optimism would cost you $2-5
Just like Uniswap, there are many other applications you can use on L2s, and the list is growing every day. Here’s an example of all the apps available on Arbitrum
Closing thoughts
To conclude, here are the key takeaways from this piece:
Layer 2 is a scaling solution for Ethereum so that more transactions can happen at more affordable costs and faster speed.
L2s achieve the above by moving some transactions “off-chain” and thus reducing the number of transactions that need to be processed on the main chain.
Many apps are moving to L2 so that users can use them without paying high transaction fees.
When you read more about the long-term vision of Ethereum, the eventual goal is for people like you and me to interact with L2s and not L1s. L1s will be used as purely an infrastructure layer for large apps and when there’s a need for high security.
For everything else like swapping a token on a decentralized exchange, buying an NFT, depositing funds to earn some yields, interacting with smart contracts - all this will happen on L2 where the fees are much lower.
There’s already been a big migration to living on L2 and this will accelerate as move applications move to L2. There still are risks involved, but that’s the direction we’re headed!
Thanks for making it this far. For more content like this, don’t forget to subscribe! and if you enjoyed this article, help support by liking and sharing!