Previous articles introduced layer0-3, let's review the definitions first.
Layer1#
Layer1 is the underlying blockchain. Ethereum and Bitcoin are both Layer1 blockchains because they are the foundation on which various Layer2 solutions are built. Examples of Layer2 projects include "Rollups" on Ethereum and the Lightning Network based on Bitcoin. All user transaction activities on these Layer2 projects can ultimately be traced back to the Layer1 blockchain.
Ethereum also serves as the data availability layer for Layer2. Layer2 projects publish their transaction data to Ethereum, relying on Ethereum to achieve data availability. This data can be used to determine the state of Layer2 or to dispute transactions on Layer2.
Layer2#
Layer2 is a collective term used to describe a series of specific Ethereum scaling solutions. Layer2 is an independent blockchain that extends Ethereum and inherits Ethereum's security guarantees.
Why do we need Layer2?#
The three main attributes of blockchain are decentralization, security, and scalability. Simple blockchain architectures can only achieve two of these attributes, and having a secure and decentralized blockchain means sacrificing scalability.
Currently, Ethereum has reached the limit of its network capacity, processing over a million transactions per day, with each transaction having high demand. The success of Ethereum and its usage demands have led to a significant increase in gas fees. Therefore, the demand for scaling solutions is growing. This is why Layer2 networks were created.
The main goal of scalability is to improve transaction speed (faster confirmation of transactions) and transaction throughput (increased transactions per second) without compromising decentralization or security.
The Ethereum community has taken a firm stance and will not sacrifice decentralization or security for scalability. Until sharding is implemented, the Ethereum mainnet (Layer1) can only process about 15 transactions per second. As Ethereum usage increases, the network becomes congested, increasing transaction costs, which makes it difficult for users to afford. This is why we are currently using Layer2 networks to scale Ethereum.
Benefits of Layer2#
1. Lower costs
By combining multiple off-chain transactions into a single Layer2 network transaction, transaction fees are significantly reduced, making it easier for everyone to participate.
2. Security maintenance
Layer2 blockchains settle transactions on the Ethereum mainnet, allowing users to benefit from the security of the Ethereum network.
3. Scalability
With increasing transaction volume, lower transaction fees, and advancements in technology, projects will expand to new applications and improve user experience.
Layer2 off-chain scaling solution - State Channels#
There are currently three popular Layer2 off-chain scaling solutions: state channels, sidechains, and rollups. This article will first provide a detailed introduction to state channels.
The core idea of state channels is to separate the transaction process from the main chain and move it offline (i.e., transact within the state channel), and then transmit the final result of the transaction back to the main chain.
The diagram below illustrates state channels:
State channels are the first scaling solution for Layer2. They are used when two or more users want to conduct a series of transactions in a trusted environment without paying gas fees for each transaction.
You may still be confused, so let's take a small example. Suppose someone has developed a tic-tac-toe game on Ethereum, and the two players (Player A and Player B) need to deposit 10 ETH each, with the winner receiving the other player's 10 ETH deposit.
If each move in the game needs to be recorded on the chain, it means that gas fees need to be paid for each move, and the final gas fees will be very expensive, even exceeding the reward received.
Is there a way to reduce these gas fees? That's where state channels come in. State channels are like opening a small room off-chain for game players. I don't care how you play, I only care about who wins, and I only need to transmit the result of who wins back to the Ethereum main chain.
In the previous example, using state channels only requires paying gas fees twice: once when starting the game to open the state channel, and once when ending the game to close the state channel.
In addition to reducing transaction costs, state channels also have the potential benefit of enhancing privacy because only the start and end states are written on the main chain, while every step of the actual gameplay is conducted off-chain and not publicly visible.
At first glance, state channels seem perfect, but they have a significant drawback: they need to be established in a trusted environment, meaning that the two players in the game trust each other.
For example, if one person goes offline during the game, the state channel can never be closed. The inability to close the channel will prevent the other person from receiving their reward, and they won't even be able to retrieve the initial 10 ETH deposit.
That's a brief introduction to state channels. In the next article, we will continue to explain other Layer2 solutions.