Blockchains/solutions which are built on top of layer blockchains.
House Analogy: the installation of a house; the plumbing, electrical systems, heating, and cooling in a house. These systems make the house livable and functional but aren’t the basic structure.
Purpose: increase the capability of the number of transactions per second the blockchain can handle (scalability) whilst also improving interoperability, and aiming to maintain the security and decentralization of layer 1.
Note: Layer 2 solutions are commonly referred to as OFF-CHAIN SOLUTIONS
Scalability
Layer 2 solutions help improve transaction speed and scalability by moving transactions off the main blockchain and onto layer 2 networks which are more efficient, but the final outcome is recorded on the layer 1 blockchain.
Examples of layer 2 blockchains:
- Polygon: Layer 2 blockchain which aims to improve Ethereum’s scalability through faster transaction speeds and lower costs for developers.
- Arbitrum: layer 2 solution (blockchain) for Ethereum blockchain, designed to improve the speed of transactions, decrease fees, increase scalability, and boost network privacy and security.
There are different types of layer 2 solutions:
- State channels
- Side chains
- Off-chain protocols
State Channels
Off-chain channels which are like side paths separate from the main blockchain, which allow participants to conduct multiple transactions without directly involving the layer 1 blockchain. However, once participants are done with the transactions in the off-chain channel, they must ‘close’ the channel, which involves ultimately recording the final state of all their transactions onto the layer 1 blockchain.
State channels purpose: handling MULTIPLE TRANSACTIONS.
Sidechains
Sidechains are like side roads that connect to the main road, they are independent blockchains that connect to the main blockchain (layer1). They operate alongside the main layer 1 chain but have their own ways of validating transactions (consensus mechanism) and rules.
Side chains also use a two-way peg system that links the main layer 1 blockchain to the sidechain, which allows assets (like cryptocurrency) to be securely moved between them. Like a checkpoint between a main road and a side road, where you can switch roads securely.
Side chains purpose: validating transactions and transferring assets.
Off-chain Protocols
Off-chain protocols enable fast and scalable transactions by conducting them off the main blockchain through establishing payment channels among participants, facilitating instant and low-cost transactions, with final settlement recorded on the layer 1 blockchain.
Examples include: Lightning Network for Bitcoin and the Raiden Network for Ethereum.
Here’s how the Lightning Network works:
- Two users agree to transfer some coins between themselves. In order to do this, they first move their coins to a special address. This is like putting their money into a shared safe where both need to agree to open it.
- The address only releases the funds when both parties agree on the conditions of the transfer. Think of it as a contract that says both parties must agree before any money moves out of the safe.
- Instead of recording every detail of their transaction on the main blockchain (layer 1), they keep a private record of their transactions. the private record is like a secret notebook that only they can see, and it doesn’t immediately tell the main layer 1 blockchain what’s happening.
- When the transfer is completed, the private ledger reports to the main blockchain. The main blockchain updates both users’ balances accordingly.
Summary: transfer of funds on a unique private ledger which then notifies the main ledger (layer1 blockchain) once the transfer is complete and confirmed.
Purpose of lightning network: allows for the creation of countless unique ledgers, so thousands of transfers can occur simultaneously without slowing down the main bitcoin protocol (layer 1 blockchain) thus helping overcome the issue of scalability.