What are Layer-2 solutions? A guide to L-2 blockchains
Many believe Layer-2 solutions could be the answer to blockchain’s scalability problems. Here’s what you need to know about them.
By Sankrit K
The security and decentralization of blockchain comes at the cost of another important factor: speed. For a long time, using blockchain for everyday commerce was completely out of the question. Buying a cup of coffee with Bitcoin? A pipe dream.
But as it turns out, there is a growing appetite for speedy crypto transactions. Around 2011, something called a “Layer-2 solution” emerged to address it.
This article explores what Layer-2 solutions are and how they can be used to improve the scalability of existing blockchains.
What is a Layer-2 solution?
A Layer-2 solution refers to infrastructure built on top of an existing blockchain that can execute transactions off-chain. While they process transactions separately, Layer-2 blockchains are still secured by the underlying Layer-1 blockchain.
Imagine a busy highway that connects different cities. This highway represents the main blockchain, which is used by many people to transfer assets and information.
As more people start using the highway, however, it becomes congested and slows down, making it difficult for people to quickly and efficiently move their assets and information.
To solve this problem, a Layer-2 solution is built on top of the highway, similar to building an elevated expressway on top of an existing road. The Layer-2 solution acts as a parallel road that can handle a large number of transactions and data transfers, while still being attached to, and secured by, the main Layer-1 blockchain.
How do Layer-2 blockchains improve Layer-1 blockchains?
A Layer-2 blockchain is designed to improve a Layer-1 blockchain's scalability by taking some of the heavy lifting from the main (Layer-1) chain to increase throughput and lower transaction fees.
This is achieved by allowing transactions to take place off-chain and only recording the final result on-chain. This way, the load on the main chain is significantly reduced, resulting in less throughput and improved performance.
The goal is to make the main chain be used for fewer transactions with lower fees, which increases transaction speed.
Here’s another analogy: imagine being at a bar with your friends.
As you order drinks, you learn of the establishment's policy: only one drink can be ordered at a time, and the next can only be ordered after the first is paid for. This can make the experience unenjoyable for all involved, as you have to deal with change for every drink, and the bartender has to keep track of whether or not you've paid the right amount, thus slowing down service for other customers.
An ideal solution would be for the bartender to keep a running tab of all your drinks on a computer, allowing you to settle the total amount with your credit card when you and your friends are ready to leave.
In our analogy, the Layer-2 solution is like the computer that keeps a tab of all transactions, which are later settled on Layer-1.
With a Layer-2 solution, only the final result of a transaction is recorded on the main chain. The number of transactions that can take place is limited only by the capacity of the Layer-2 solution and not by the main chain.
These Layer-2 solutions are built on top of Layer-1 blockchains and leverage several of their properties. For instance, some solutions like rollups and state channels derive their security from the main chain (Layer-1).
Limitations of Layer-1 blockchains
Layer-1 is the “base layer” of a blockchain network. It’s like the foundation of a building and provides the basic structure that allows for decentralized apps and services to be built on top of it.
Think of it as the starting point for more complex blockchain solutions.
Most first generation blockchains (like Bitcoin and Ethereum) are not scalable because they can only process a handful of transactions per second. In the case of Ethereum, for most of its existence as a Proof-of-Work network it could only process 15 transactions per second. Visa, by contrast, can process 1,700 transactions per second.
Such low throughput is not enough to meet the demands of modern commerce.
If blockchain is to be used for day-to-day commerce, it must be able to scale to meet the demands of real-world usage.
To sum up, the limitations of Layer-1 blockchains include:
- Poor scalability
- Low throughput
- Energy-intensive
This is where layer-2 solutions come in.
It should be noted that there are some Layer-1 blockchain projects (like NEAR Protocol and Solana) attempting to overcome the limitations mentioned above.
The benefit of Layer-2 solutions is that they are built atop popular existing Layer-1 blockchains and can leverage those blockchains’ security, trust, and ecosystem benefits.
To learn more about Layer-1 blockchains, see our article What is a Layer-1 blockchain?
Types of layer-2 scaling solutions
Optimistic rollups
In optimistic rollups, the validity of the data is checked before it is included in the rollup. This is done by having a "challenge period" during which any party can contest the validity of the data. If the data is invalid, it is excluded from the rollup.
This type of rollup is more secure but slower, as it requires data to be verified before it is included in the rollup.
Advantages of optimistic rollups
- Security derived from the main chain
- Low transaction fees
- Trustlessness
- Good incentive structure
Disadvantages of optimistic rollups
- Larger transaction finality
- More centralization
- Relies on honest validators and sequencers
ZK (zero-knowledge) rollups
ZK rollups use “zero-knowledge proofs” to validate data before it is included in the rollup. This way, data can be added to the rollup without having to verify it first.
A zero-knowledge proof is a mathematical way to prove something is true without revealing any information about it.
The way this works is that when a transaction is made, a zero-knowledge proof is generated to prove that the data in the transaction is valid. This proof is then included in the roll-up along with the transaction data.
This makes ZK-rollups much faster than optimistic rollups, as data doesn't need to be verified before it is included in the rollup. Instead, it only has to be proved that the data is correct.
Advantages of ZK rollups
- Avoids incorrect state changes
- Faster finality periods
- Maintains integrity of decentralization
- Low withdrawal delays
Disadvantages of ZK rollups
- Expensive hardware requirements can risk chain centralization
- Ethereum Virtual Machine-compatible ZK rollups are expensive
- Centralization may lead to greater censorship
State channels
A blockchain is essentially a deterministic state machine. This means that the state of the blockchain is determined by the sequence of transactions that have taken place on it.
The "state" is simply the data that is stored on the blockchain at a given time. This includes account balances, smart contract codes, and more. Altering the information changes the state, which is one way to spot malicious activity.
State channels are a type of Layer-2 solution that allows two parties to transact with each other without having to record every transaction on the main blockchain.
They work by first locking a small part of the mainnet's (main chain) state using a multi-sig or a smart contract (called "judge contract").
Then a few transactions are made and submitted to the main chain, which alters the state. This is crucial to ensure that transactions processed off-chain are not malicious.
Now that the security has been established, an indefinite number of transactions can be executed off-chain before submitting to the main chain. This exponentially increases the network's throughput.
Advantages of state channels
- Instant finality
- Finality speed is independent of mining power
- Cost decreases when used over longer periods
Disadvantages of state channels
- All participants must be available
- No open participation
- The initial cost of deploying a judge contract is high
Side chains
A side chain is a blockchain connected to a main blockchain using something called a "two-way peg.”
A two-way peg allows tokens to be moved from one blockchain to another. This is done by locking the tokens on the main chain and minting an equivalent number of tokens on the side chain.
The advantage of using a side chain is that it allows for more flexibility in terms of governance and consensus. This is because a side chain can have its own rules and consensus mechanisms that are different from the main chain.
This makes side chains particularly well suited for processing transactions that are not suitable for the main chain, such as high-risk or experimental transactions.
Advantages of side chains
- Easily upgradeable
- New participants don't require new side chains
- Functions can be tested before moving to the main chain
- Compatible with Ethereum Virtual Machine
Disadvantages of side chains
- Doesn't derive security from the main chain
- Require greater trust assumptions
- High initial costs
Off-chain computation
Off-chain computation, a.k.a. oracle computation, is a type of Layer-2 scaling solution that allows for computationally intensive tasks to be performed off-chain.
This is done by first locking a state on the main chain and then executing the computation off-chain. Once the computation is complete, the result is submitted to the main chain, and the state is updated.
This allows for a much wider range of computations to be performed on a blockchain, as the off-chain computation can be performed by anyone with the necessary resources.
It also reduces the load on the main chain, as computationally intensive tasks are performed off-chain.
Advantages of off-chain computation
- Highly cost-efficient
- High degree of customizability
- dApps can be highly scalable
Disadvantages of off-chain computation
- No guarantee of data availability
- Application liveness is affected
- Risks of centralization
Plasma
Plasma is a type of Layer-2 solution that allows for the processing of large numbers of transactions off-chain.
It does this by first dividing the main blockchain into smaller blockchains, called "Plasma chains" or "child chains." This is done by using smart contracts and Merkle trees.
These Plasma chains can then be processed independently of each other, and the results are submitted back to the main blockchain.
This allows for a much higher degree of scalability, as each Plasma chain can process transactions independently of the others.
Advantages of Plasma
- Extremely scalable
- Good for high-risk transactions
- Suited to create private blockchains
- Compartmentalizes network usage
Disadvantages of Plasma
- Long withdrawal times
- Cannot scale general-purpose smart contracts
- Greater centralization
Examples of popular Layer-2 scaling solutions
While this list is not exhaustive, here are some common layer-2 blockchains and scaling solutions.
Polygon (formerly Matic Network)
Polygon (MATIC) is a Layer-2 solution that uses Plasma chains to scale Ethereum. It is one of the most popular scaling solutions currently available, with over 19,000 dApps using Polygon to scale up.
Lightning Network
The Lightning Network is a Layer-2 solution for Bitcoin that uses bidirectional payment channels (a type of state channel) to process transactions off-chain.
It is one of the most popular scaling solutions, with over 30,000 lightning nodes.
Loopring
Loopring is a Layer-2 solution that uses zk rollup to process Ethereum transactions off-chain.
With Loopring, users can be involved in the non-custodial exchange and payment protocols without sacrificing the security offered by Ethereum. It is open-source, trustless, and audited.
The future of Layer-2 solutions
Layer-2 solutions are becoming increasingly popular as the need for scalability grows. With the rise of dApps and NFTs, it is clear that Ethereum and other Layer-1 blockchains cannot keep up with the demand.
Layer-2 solutions like Base Chain offer a much-needed scaling solution and will likely become more prevalent in the future. Many expect to see more innovation and adoption of these solutions in the future.
On the other hand, many argue that Ethereum's sharding update and the emergence of faster Layer-1 blockchains like Solana (with 65,000 TPS) and Near (400,000+ daily transactions) may reduce dependency on Layer-2 solutions.
While it can’t be known which Layer-2 solutions will stand the test of time, it’s all but certain that the scalability of blockchains will continue to evolve and grow.
Begin your layer-2 crypto journey with MoonPay
Now you know the basics of layer-2 blockchain technology, it’s time to experience it for yourself.
To get started, simply buy cryptocurrency via MoonPay using your credit card or any other preferred payment method. Choose from layer-2 cryptocurrencies like Polygon (MATIC) and Immutable (IMX) and send directly to your non-custodial wallet.