article cover image
View all Articles

What is a Layer 2? A Detailed Introduction (2024)

The term "layer 2" pertains to a collection of off-chain solutions (network, system, or technology) that are constructed atop a layer 1 blockchain.

Last Updated:
Tags:
Infrastructure
Arbitrum
Base
Optimism

This guide provides an overview of the following topics:


Understanding Layer 2 Blockchains

Layer 2 refers to a collection of off-chain solutions designed to enhance the scalability of a parent network (a layer 1) by processing transactions outside that primary layer.

These solutions leverage the robust decentralized security model provided by that layer 1 while operating independently to scale the network.

ℹ️ This can be likened to constructing a small office within a large, secure building, where the office does not require its own security personnel due to the presence of the building's security team.

There are several layer 2 scaling solutions available, each with its own advantages and disadvantages, which we will explore. However, before delving into these solutions, it is essential to understand the limitations of layer 1 blockchains and the purpose of layer 2 blockchains.

Limitations of Layer 1 Blockchains

Although blockchains have proven to be highly useful, they are currently encountering real-world limitations. This is primarily due to a significant issue: their original design did not account for scalability.

ℹ️ When it comes to blockchains, scalability means being able to process more transactions per second (TPS) to keep up with the increasing number of users. Unfortunately, layer 1 networks have a hard time with this.

Bitcoin and Ethereum are prime examples of Layer 1 networks that independently manage all aspects of each blockchain transaction without any external network assistance. However, these legacy networks are notorious for their slow transaction speeds and high costs for users, which only worsen as more individuals utilize them. As a result, these networks are not practical for mainstream usage.

What makes layer 1s slow and expensive to use?

I won't delve deep into blockchain mechanics, but here's a simple takeaway: Whenever you make a blockchain transaction, like swapping ETH for UNI or transferring eth to another wallet, it needs a thumbs-up from the network. This network is essentially a group of computers running a software, all communicating to ensure no foul play. Every couple of minutes, the latest transactions get bundled into a block which is tacked onto the end of the blockchain – hence the clever name!

Imagine a growing stack of bricks where instead of placing a new brick at the top, you must place it at the bottom. This means you'd need to lift every existing brick to add a new one. As the pile grows and more bricks are needed, the task becomes increasingly tedious and time-consuming.

While this rigorous process ensures network security, it makes daily usage of the blockchain cumbersome. In essence, this is why blockchains can become slow and bogged down.

The blockchain trilemma

Three key features of a blockchain are its decentralization, security, and scalability. However, the blockchain trilemma suggests that achieving all three in a basic blockchain setup is a tall order. Want it decentralized and secure? Then you might have to compromise on scalability.

blockchain trilemma.webp

ℹ️ At present, Ethereum is capable of processing over one million transactions on a daily basis. However, the surge in demand for Ethereum usage can lead to a significant increase in transaction fees. This underscores the importance of implementing layer 2 networks.


Benefits of layer 2 blockchains

Because layer 1 blockchains can be slow and costly, we need alternatives to harness the full potential of blockchain on a grander scale. As previously noted, the primary objective of layer 2 is to boost transaction speed (more transactions every second) while maintaining both decentralization and security. Let's delve deeper into the three major advantages they offer.

1. Reduced Fees and Enhanced Efficiency for Users

Through the consolidation of multiple off-chain transactions into a single layer 1 transaction, transaction fees are significantly reduced, thereby increasing accessibility for all users.

These layer 1 blockchains offer users a considerably faster and more cost-effective means of conducting transactions. By keeping low-value transactions off-chain, users can transfer their crypto assets quickly and with minimal network costs.

2. Ensuring Security and Easing the Load on the Mainnet

Layer 2 blockchains settle their transactions on Ethereum Mainnet, allowing users to benefit from the security of the Ethereum network.

This helps not just individual users but the entire crypto community. By moving much of the activity off-chain, the mainnet faces less traffic, making transactions on it faster and smoother.

3. Enabling more use cases

With faster transactions and lower fees, layer 2 solutions are making it possible to do all sorts of useful and fun stuff which means we're seeing even more possibilities for blockchain applications.

One prime example is transfering value quickly and efficiently: just look at El Salvador, where Bitcoin is now legal tender! This wouldn't have been possible without the Lightning Network's speed and efficiency. Exciting stuff, right?


Different types of layer 2

There's a variety of layer 2 solutions, each with its own set of advantages, drawbacks, and security models. Let's explore some of these in relation to Ethereum.

Rollups

Rollups work by aggregating, or 'rolling up', multiple transactions into a single one on layer 1. This spreads the cost of the L1 transaction fee among all the participants in the rollup, making it more cost-effective for each user. A simple analogy would be using a bus: it's more economical since the fuel cost is divided among all the passengers.

While rollup transactions are executed outside layer 1, their data is still sent to layer 1. Once the data is on layer 1, to undo a rollup transaction, you'd have to undo a transaction on Ethereum itself.

There are two major categories of rollups: optimistic and ZK Rollups. Both types consolidate transactions, but their key difference lies in the method of sending this consolidated data to L1.

Optimistic rollups

Optimistic rollups operate on a principle of trust but verify. They initially assume all transactions are valid, yet they allow anyone to come forward and challenge a transaction's legitimacy by running a fault proof to verify the suspicion.

Networks like Optimism, Arbitrum, and Base employ this technology. It has gained significant traction and, in terms of development, stands a bit ahead of ZK rollups.

Zero-knowledge rollups

Zero-knowledge rollups leverage validity proofs. Transactions are processed off-chain, and then a condensed version of the data is sent to the Ethereum Mainnet, serving as evidence of their legitimacy.

In essence, anyone can verify the legitimacy of a transaction by examining its proof, without needing details about the actual transaction. It's founded on the zero-knowledge proof technology, which is quite a remarkable feat.

Validum

Besides zkRollups and Optimistic Rollups, there's a third category of layer 2s: Validium (it’s what powers Immutable X). While it employs a ZK Proof processed by the Ethereum blockchain, it diverges from ZK Rollups by not storing data on-chain. Instead, user balances are dispatched off-chain to a selection of reputable, trusted entities. Because of this, some people don't see Validium as true Layer 2s.

Sidechains

A sidechain operates as an independent blockchain that's linked to the Ethereum Mainnet via a two-way bridge. While sidechains function concurrently with Ethereum and communicate with it through these bridges, they don't inherit security or data availability from Ethereum. Sidechains can have their own block parameters and consensus mechanisms, typically optimized for fast transaction processing. Unlike layer 2 solutions, sidechains don't relay transaction data or state alterations back to the Ethereum Mainnet.

Still, sidechains offer benefits similar to layer 2 solutions – they provide reduced transaction costs and increased transaction speeds. Yet, they come with distinct trust dynamics. Because they might compromise on decentralization or security to boost throughput, many don't classify sidechains strictly as layer 2 solutions.


Another way to look at layer 2 solutions is through the lens of being either generalized / universal or application-specific.

Generalized Layer 2s

Generalized layer 2s operate similarly to Ethereum, only at a lower cost. Any activity achievable on Ethereum layer 1 can be executed on these layer 2 solutions. Several dApps are already transitioning to these networks, with some even bypassing the Mainnet to launch directly on a layer 2. Notable examples of generalized layer 2 platforms include Arbitrum One and Optimism.

Application Specific Layer 2s

These layer 2 solutions are tailored for particular application areas, offering enhanced performance tailored to that niche. Loopring's zkRollup L2, for instance, is designed to deliver a cost-effective, rapid platform for trading, swapping, liquidity provision, and payments. Aztec Network stands out as Ethereum's inaugural private zk-rollup, facilitating dapps to tap into both privacy and scalability. Meanwhile, Immutable X centers its attention predominantly on NFTs and gaming.


Now, let's dive into some of the prominent layer 2 solutions within the Ethereum ecosystem. Keep in mind, this overview is not comprehensive, nor does it aim to be. Additionally, it's crucial to understand that there isn't a one-size-fits-all "best" layer 2. Each has its unique features, and not every application can be found on every network.

1. Optimism

Optimism stands out as a speedy, straightforward, and secure optimistic rollup that's EVM-compatible. It sits on top of Ethereum's tech while also promoting its core values by endorsing retroactive public goods funding.

2. Arbitrum One

Arbitrum One is an Optimistic Rollup designed to feel exactly like using Ethereum, but at a mere fraction of the transaction costs. It boasts a lively DeFi ecosystem and is host to lots of innovative on-chain games.

For developers, particularly those familiar with C++ and Rust, Arbitrum recently unveiled Stylus – a tool that permits the creation of smart contracts in languages other than Solidity. Stylus appears to be highly memory efficient, paving the way for the development of apps with intricate logic.

3. Base

Base is the newest entrant in the Layer 2 arena, receiving support from Coinbase. Its mission is to usher in the next billion users into the web3 world. At its core, it's constructed on the OP Stack, positioning it as an Optimistic rollup. This foundation ensures that Base is secure, cost-effective, and amenable to developers.

Although its app repertoire isn't as extensive as that of Optimism or Arbitrum, Base proudly hosts the well-liked social app, Friend.tech.

4. ZkSync

zkSync Era is a layer 2 system that boosts Ethereum by using special math called zero-knowledge cryptography. zkSync's goal isn't just to make Ethereum faster, but to also keep its core beliefs.

5. Starknet

StarkNet aims to solve the Blockchain Trilemma by creating a system that's balanced, decentralized, fast, and safe using special math called zero-knowledge STARK proofs.

6. Polygon

Last but not least, let’s talk about Polygon. Presently operating as a sidechain, it's on the pathway to potentially transition into a rollup that derives its security backbone from Ethereum.

Polygon is liked by many because it's cheaper and faster. When Ethereum gets busy and fees go up, Polygon offers a cheaper and quicker option for most.

⚠️ Most layer 2 projects are still new, and sometimes you have to trust certain players to play fair as these projects try to spread out control. Always DYOR and think carefully before jumping in, so you're okay with any risks. For a deeper dive into the tech, risks, and trust factors of layer 2s, you might want to visit L2BEAT. They have detailed risk checks on each project.


Takeaways

If you didn’t read the whole post, I have included below the main takeaways:

  1. Bitcoin and Ethereum, though revolutionary, face scalability issues. Their designs are unable to efficiently handle a vast number of transactions, leading to slower speeds and higher fees. And that’s why we need "Layer 2" solutions.

  2. Layer 2 is a term that refers to off-chain solutions built on a primary "layer 1" blockchain. These aim to improve a blockchain's scalability without compromising its foundational security.

  3. Layers 2 offer many benefits:

  • Consolidating multiple transactions into one results in significantly lower fees.
  • Transferring most activity off-chain relieves traffic on the mainnet, making on-chain transactions faster.
  • Speedy transactions and reduced costs enable various applications, from fast value transfers to gaming.
  1. Types of Layer 2 Solutions:
  • Rollups: They aggregate several transactions into one on layer 1, distributing the transaction fee. There are two kinds: Optimistic Rollups: Operate on trust but verify principle. Notable examples include Optimism, Arbitrum, and Base.
  • Zero-knowledge Rollups: Use condensed transaction data as validity proofs. Sidechains: Independent blockchains linked to a mainnet but don't inherit its security. Generalized vs. Application-Specific: Generalized Layer 2s act like Ethereum but cheaper. Application-specific ones cater to niche use-cases.
Maxime Servais

Article by

Maxime Servais

I'm a Software Developer and Tech Writer over at Ethereum Ecosystem. Basically, I make sure everything we cook up is top-notch and awesome!