Blockchain is like onions, they both have layers. Onions have layers. Blockchain Also has layers.
Let’s peel back the layers of the blockchain one by one!
What is a layer 1 blockchain?
Layer 1 is the base blockchain; it can validate and finalize transactions through its own network. Examples of layer 1 blockchain projects are Bitcoin, Ethereum and Cardano.
Layer 1 blockchain networks have their own native token, also called a coin, which is used to pay transaction fees.
Scaling with Layer 1
Layer 1 networks have scaling issues. When the blockchain struggles to process the number of transactions required by the network, transaction fees increase.
When you approach scaling, you are faced with the Blockchain Trilemma, term coined by Vitalik Buterin. This is where you try to balance decentralization, security and scalability. All scaling solutions will attempt to find a balance between these three elements.
You can also fund a number of supernodes (by purchasing supercomputers, large servers, etc.) to secure and scale your network. But this would centralize your blockchain.
There are three main approaches to improving Layer 1 scalability: block size, change the consensus mechanismAnd fragmentation.
Increase block size
If a Layer 1 network is struggling to handle the required number of transactions, you can increase the block size. This will allow more transactions to be processed in each block.
However, this is only of limited scope. Larger block sizes can also end up slowing down transaction speeds due to the download required for the block data. This is why you can't just create an infinitely large block. Larger blocks would also reduce decentralization.
Changes to the consensus mechanism
Some consensus mechanisms are less scalable than others.
For example, the proof-of-work consensus mechanism is less durable and scalable than proof-of-stake. This is why Ethereum is slowly moving from the former to the latter.
We have already covered consensus mechanisms in more detail here.
Sharing
Simply put, Sharding involves dividing a set of data into smaller, more manageable groups. fragments. It's a simple way to distribute the load. Think about eating a cake, it is much easier to eat once it is sliced and distributed to other people.
Sharing increases transaction output by dividing the network into different fragments. Due to the way the network is split, each shard does not contain all the information of the blockchain. Once a node is finished with its shard, it broadcasts it to the blockchain, where it is then validated.
This helps distribute the workload and, therefore, increases the speed of transactions.
What is Layer 2?
Layer 2 protocols are built on top of the Layer 1 blockchain to address Layer 1 scalability issues.
This is done by creating a secondary frame, which does not need the layer 1 chain, also called “off-chain”.
Two things that Layer 2 can improve are transaction speed (how long a transaction takes) and transaction throughput (how many transactions the network can process in a set period of time).
When the Layer 1 network becomes congested, Layer 2 can take over to improve transaction times and reduce transaction fees.
How it works?
Layer 2 can solve Layer 1's scalability problem in several ways.
Canals
Channels are a layer 2 solution that allows users to make multiple transactions off-chain before reporting them to the base layer.
There are two types of channels: state channels And payment channels. Payment channels are simple; they allow payments to be processed off-chain. On the other hand, state channels are a little wider; they allow all interactions that could happen on the blockchain to happen off-chain (e.g. smart contracts).
The problem with this solution is that users must be known to the network, which means open participation is not an option. These users will also need to lock their tokens in a multisig contract.
Plasma
Created by Joseph Poon and Vitalik Buterin, Plasma uses smart contracts and digital trees to create “child chains,” which are copies of the original blockchain, also known as the “parent chain.”
This framework moves transactions away from the original chain to the child chain, in order to improve transaction speed and reduce transaction fees.
However, the plasma solution cannot be used to help scale general-purpose smart contracts. Additionally, users have to wait for a certain amount of time before they can withdraw their money from Layer 2.
Side chains
Sidechains have their own independent blockchains that use their own consensus mechanisms and block requirements. They can connect to Layer 1 using the same virtual machine. This means that all contracts and transactions that can be used on layer 1 can also be used on sidechains.
Accumulations
The rollup solution groups (or rolls up) sidechain transactions into a single transaction to generate cryptographic proofs called cryptographic proofs. SNARK (succinct and non-interactive argument for knowledge). Once the SNARK is generated, it is broadcast to the base layer.
There are two types of accumulations: ZK accumulations And optimistic accumulations.
Optimistic rollups use a virtual machine that facilitates migration from Layer 1 to Layer 2.
ZK rollups are faster and more efficient, but don't use a VM because it makes moving between layers more difficult.
What are Layer 0 protocols?
Layer 0 protocols enable cross-chain interoperability between Layer 1 projects. This is a major problem with Layer 1; once you're in the ecosystem, it's quite difficult to move to another – layer 0 fixes this problem.
Not all blockchains built on the same layer 0 will have the same design. They can use different consensus mechanisms, block parameters, etc.
Often, layer 0 tokens act as a spam filter, requiring you to stake the layer 0 token to access their ecosystem.
Example of layer 0
Cosmos is the best-known example of a layer 0 protocol.
They provide open source tools such as Soft mint, Cosmos SDKAnd IBC to help developers easily create their own blockchains that can communicate with each other. Their goal is to create the “Internet of Blockchain”.
Projects like Binance, Crypto.comAnd Polygon were created using Cosmos.
Does layer 3 exist?
Yes!
Layer 3 is the protocol(s) that enable blockchain-based applications such as dApps, gaming, storage, etc. Layer 3 is often referred to as the “application layer.”
The “application layer” provides information to layer 1 for processing (e.g. smart contracts). Without applications, layer 1 protocols would be pretty boring. Layer 3 is what gives the core blockchain any function outside of just transactions.
Most layer 1 blockchains allow you to easily create layer 3 projects directly on their network, but this is not possible with Bitcoin. Some forks of Bitcoin are attempting to introduce dApps to the network, but we have yet to see a real Layer 3 project on the core Bitcoin network.
Bitcoin might be missing something, as blockchains like Ethereum, Solana, and Cardano have thriving layer 3 ecosystems enriching their blockchain.
Often these projects have cross-chain features, like Uniswap, which allows users to exchange assets on different blockchains.
It may be important to note that each blockchain uses a different programming language. This means that Layer 3 applications that provide cross-chain functionality must be multilingual. For example, translating from Solidity for Ethereum to Haskell for Cardano.
Layer 3 gives the layers below real-world applications outside of simple transactions. Now you can mint NFTs, trade your tokens, play games and much more. The application layer unlocks the full potential of the blockchain.
Does layer 4 exist?
No. The layers we talked about are often called four layers of blockchainbut that's because we start counting from 0 in the programming world.
Conclusion
Blockchain has many layers and they are all quite important. Let's quickly recap them all:
-
Layer 1: The basic blockchain network. They validate and finalize transactions but have scaling issues (e.g. Bitcoin).
-
Layer 2: A scaling solution for Layer 1 protocols. It creates a secondary framework that is used for “off-chain” transactions (e.g. Bitcoin Lightning Network).
-
Layer 3: Enables blockchain-based dApps, games and more. Also known as application layer (e.g. Uniswap).
-
Layer 0: Enables cross-chain interoperability between Layer 1 protocols (e.g. Cosmos).
This article is part of the Hashnode Web3 Blog, where a team of selected editors offers new resources to help you discover the world of web3. Visit us to learn more about NFTs, DAOs, blockchains and the decentralized future.