A layer 2 solution is a protocol that sits on top of a core blockchain (layer 1) and is designed to increase its scalability.
L2 solutions are used for popular low-bandwidth blockchain platforms such as Ethereum and Bitcoin.
The Layer 2 solution is deeply integrated with the core network, with compatible smart contracts and crypto assets.
In the case of Ethereum, a cross-chain bridge is required to transfer cryptocurrency between the core network and Layer 2.
What are Layer 2 solutions for?
Blockchains have an inherent problem known as the “scalability trilemma”. It lies in the difficulty of creating a network that is simultaneously fast, decentralized, and secure. As a result, developers often have to choose and optimize at most two of the three components.
The architecture of early blockchains, primarily bitcoin and Ethereum, was not designed for large numbers of transactions and users, and therefore has low throughput. For example, bitcoin has 5-7 transactions per second (TPS), and Ethereum has about 15 TPS.
Scalability can be improved by modifying the blockchain protocol code with features such as sharding. However, this is time consuming and could take years. In addition, such improvements change the fundamentals of the architecture, so the project community does not always agree to implement them.
L2 solutions can at least partially solve the problem of low bandwidth and high transfer fees without affecting the underlying blockchain code. Their main advantage is the ability to transfer assets between “first-tier” addresses while using a “second-tier”, which can be either a separate off-chain protocol or a separate blockchain.
What are Layer 2 solutions for Bitcoin?
The main L2 project for the first cryptocurrency is the Lightning Network (LN). It operates on a protocol that uses smart contracts and so-called state channels. The Lightning Network was launched in 2015 and has been developing rapidly ever since. By the end of May 2022, the total capacity of LN channels reached 3,900 BTC.
The main function of the LN is the ability for bitcoin holders to make direct exchanges without writing information to its registry. To do this, you need to open a special channel with a single on-chain transaction and place bitcoins in it.
Once activated, the payment channel allows for off-chain transfers, outside the main network, at much faster speeds and lower fees. Unlike on-chain transactions, transactions in Lightning Network channels are only visible to their users. Only the initial and final states of transactions are recorded on the main blockchain.
This approach significantly reduces the load on the main bitcoin network: the Lightning Network is capable of processing thousands of transactions per second while maintaining a high level of system security.
How are payment channels protected in Lightning Network?
The channel is verified by its participants and their mutual smart contracts. Upon completion of an off-chain exchange, the final state is recorded in a new block of the underlying network. Smart contracts protect transactions within state channels and also act as “judges” in the relationship between participants.
Some channels use a timer that automatically updates or locks the on-chain state of transactions. When the timer expires, the system automatically triggers the closing transaction, then updates the main blockchain and closes the state channel based on the last verified transaction. Any new attempt to unlock the state channel creates a new encryption and restarts the timer.
What Layer 2 solutions exist for Ethereum?
Despite its slow speed, Ethereum is the most heavily used blockchain platform for decentralized applications. Many popular decentralized finance (DeFi) and non-exchangeable token (NFT) projects run on it. Therefore, the scalability problem is particularly acute for Ethereum.
There are several major L2 solutions being developed in parallel:
- Polygon (MATIC);
- Arbitrum;
- Optimism.
The main technology for their work is rollups, which have two main variants:
- Optimistic Rollups. With this solution, transactions are made in the L2 network, and then in large groups are combined into a compact block, which is included by validators in the main Ethereum network. Optimistic rollups are used in Arbitrum and Optimism.
- ZK rollups. Layer 2 network transactions are also bundled into packets and sent to the Ethereum network, but they are validated by special verifiers that cryptographically prove the validity of the transaction. Based on ZK-Rollups, Polygon is implemented. This technology for Ethereum scaling is considered by the main co-founder of the platform, Vitalik Buterin.
Whatever the L2 solution, Ethereum as the “first layer” takes over the function of transaction validation and block production, a registry where final states are recorded, and a consensus mechanism. Thus, the project does not need to build its own infrastructure.
There are other Layer 2 projects. For example, in July 2022, the startup Matter Labs announced the launch of zkSync 2.0. A month later, StarkWare launched its own protocol, written in Cairo.
How do you transfer assets from the Layer 1 network to Layer 2 network?
To transfer cryptocurrencies from the Layer 1 blockchain to the L2 network, you need to use crosschain bridges.
To work with them, you need a browser-based Web3 wallet, such as MetaMask or WalletConnect. In the wallet’s settings, you must first add the desired network – for example, Optimism.
The project has its own official bridge. On the bridge website, choose the asset you want to transfer, enter the amount, confirm the transaction, and you’ll get the same tokens in return, but already L2 networks. Polygon and Arbitrum have their own bridges as well.
Cryptocurrencies of L2 networks can be used almost without restrictions as “original”, e.g. for transfers or trading on decentralized exchanges or DeFi protocols. Most major applications support second-tier solution assets. Uniswap calls this approach “multichain”.
Are sidechains part of the Layer 2 solution?
Sidecards like those used by Cosmos or Polkadot are not second-tier solutions. While the former use their own security system, the latter rely on the “parent” blockchain for this purpose.