In this “Blockchain: Layer-1 vs Layer-2” article, we’re going to explore the differences between layer-1 vs layer-2 scaling solutions. We’ll discuss how layer-1 and layer-2 solutions operate. Plus, we’ll take a look at some of the different technologies powering these scaling solutions and the projects developing them.

Moralis Academy is the ultimate Web3 and blockchain education platform online. Check out the Bitcoin & Blockchain 101 course at Moralis Academy to gain a firm understanding of this revolutionary technology. This course teaches students about forks, consensus mechanisms, UTXOs, and more. Join our community of over 30,000 students today and start your blockchain journey with Moralis Academy. Also, save our “Top Crypto YouTube Channels” and “Bitcoin Mining Companies” articles for further reading!

Layer-1 vs Layer-2 – What is a Blockchain?

Before we look at the differences between layer-1 vs layer-2, let’s first look at the fundamental attributes of a blockchain. Blockchain is a revolutionary form of distributed ledger technology (DLT) at the heart of Web3. It combines computer science and cryptography to make a decentralized ledger or record of transactions. All transactions are contained in blocks and immutably interlinked with all previous transactions. This record of transactions is distributed across a peer-to-peer network of computers called nodes. Also, each node in the network must agree that each transaction is valid before it can be added to a block and appended to the blockchain. Once appended to the blockchain, transactions cannot be altered or tampered with.

Bitcoin was the first iteration of a public blockchain. It was designed to prevent “double-spending”, where an asset cannot be spent more than once. Rather than relying on a single point of failure or central authority, the Bitcoin blockchain is secured by a decentralized network of nodes. This means that governments and central banks are unable to manipulate the Bitcoin network. Also, for any changes to be made to the Bitcoin protocol, the community at large must agree to it. 

Mining

Mining nodes use computational resources to solve mathematical problems in order to validate transactions and “mine” cryptocurrencies into circulation. In return, mining nodes receive mining rewards in the form of newly generated crypto. Any bad actors within the network are penalized and are instantly identifiable by the rest of the network. Accordingly, the blockchain provides an equitable, trustless alternative to the legacy financial system.

However, one of the issues with layer-1 blockchains like Bitcoin is that they cannot scale to meet rising demand. For example, the Bitcoin blockchain can process seven (this number can vary) transactions per second (TPS), whereas Visa can process upward of 1,700 TPS. As such, scaling solutions are becoming an increasingly prominent feature in blockchain and Web3.

Consensus

For blockchain nodes to agree on the validity of a transaction, there must be a framework in place to communicate to the network. This is known as a consensus mechanism or a consensus algorithm in the case of Bitcoin. The proof-of-work (PoW) consensus algorithm requires Bitcoin nodes to expend vast amounts of computational resources to compete with other mining nodes for the right to add a transaction to their block. In short, the first miner to solve a complex mathematical puzzle wins the right to add a transaction to their block.

Despite the many advantages of this technology, the Bitcoin blockchain, like many others, is continuously growing in size. Therefore, mining nodes need an ever-increasing amount of computational resources. In many cases, this is simply not sustainable. However, layer-2 scaling solutions could prove to be instrumental in aiding this issue.

Ethereum

An increase in users alone can cause congestion on a blockchain network. However, Ethereum’s pioneering smart contract architecture has paved the way for complex smart contract transactions. Smart contracts are immutable pieces of code that sit on the blockchain. They can automate and trigger events to take place within specific parameters upon the outcome of particular scenarios. Furthermore, smart contracts underpin much of the architecture of decentralized finance (DeFi). This includes automated market makers (AMMs), decentralized exchanges (DEXs), and lending protocols.

After reading about "Blockchain: Layer-1 vs Layer-2", user initiate a layer-2 solution

Ethereum is the leading smart contract-enabled blockchain and one of the most widely used financial networks in the world. Therefore, it makes sense to look at ways of optimizing the network to increase transaction throughput and reduce fees. This is where layer-2 solutions come into play.

Layer-1 Scaling Solutions

Rather than taking computations off-chain, layer-1 scaling solutions improve features of the underlying layer-1 protocol. A layer-one blockchain such as Bitcoin, Ethereum, or Litecoin could introduce improvements to the architecture of the protocol if the network agrees to do so. Ways of doing this include increasing the transaction speed, the amount of data in each block, or by speeding up transaction confirmation times.

Furthermore, blockchain networks can move towards a different consensus mechanism like Ethereum does with Ethereum 2.0. Ethereum began as a PoW blockchain. Ethereum 2.0 marks a transition towards a proof-of-stake (PoS) consensus mechanism to increase throughput without increasing computational demands.

Sharding is another layer-1 scaling solution that breaks down the state of the blockchain into unique datasets called shards. Instead of maintaining the entire ledger of transactions for the network, sharing enables nodes to hold transactional data for one particular shard. Accordingly, sharding makes node operation more manageable by facilitating the simultaneous processing of large volumes of transactions in parallel. Moreover, sharding has become an experimental feature in many different blockchain protocols, including Ethereum and Polkadot.

What is a Layer-2 Solution?

First-generation blockchains such as Bitcoin and Ethereum have paved the way for decentralized financial infrastructures that operate outside of traditional systems. However, the blockchains cannot efficiently scale to meet the growing number of users and transactions. 

What are layer-2 solutions?

During times of network congestion, transactions can be slow and expensive on these layer-1 blockchains. However, layer-2 scaling solutions alleviate these issues by taking computations away from the main blockchain and adding them again at a later date in a timely and cost-effective manner.

Instead of making changes to the underlying protocol of the main blockchain, it is possible to improve transaction capacity by implementing a layer-2 scaling solution. A layer-2 solution takes interactions off-chain and processes them before communicating them back to the main chain. Below, we look at some of the different ways to achieve this.

Rollups

Rollups are a type of scaling solution that “roll up” several transactions and process them together as a single block away from the main blockchain. Although a substantial amount of data is taken off-chain, some essential computations remain on-chain. Furthermore, rollups harness the security of the main Ethereum blockchain while facilitating cheaper and faster transactions. As a result, this technology reduces congestion on the Ethereum blockchain and makes applications more accessible and cost-effective. Moreover, rollups come in two varieties, zk-rollups, and optimistic rollups.

ZK-Rollups

A zero-knowledge proof rollup, or zk-rollup, is an advanced scaling solution whereby transactions are batched together and contain a cryptographic proof called a SNARK. The SNARK confirms that the state of the root is correct following the execution of the batch of transactions.

Optimistic Rollups

Optimistic rollups are less centralized than zk-rollups. Also, optimistic rollups are generally easier to use. Plus, they’re Turing-complete, meaning they can simulate computational elements of other Turing-complete machines and languages. Furthermore, zk-rollups use advanced mathematical verification procedures, whereas optimistic rollups assume all transactions are valid unless a network participant claims them to be invalid.

Comparing different layer solutions and layer-1 vs layer-2 scaling solutions

Sidechains

Sidechains are somewhat of a hybrid of layer-1 and layer-2 networks. A sidechain is a sort of independent layer or “sister chain” with its own security features and consensus mechanism. It operates next to and communicates with the main Ethereum chain to facilitate asset transfers using smart contracts.

State Channels

State channels are a layer-2 solution that enables multiple transactions to occur off-chain while only two transactions are submitted onto the Ethereum blockchain. This method increases transaction throughput. However, a large amount of capital needs to be locked up to enable complex transactions.

Plasma

Plasma uses a combination of smart contracts and “Merkle trees” to establish an unlimited number of sub-networks called child chains, or plasma chains. Child chains are essentially smaller versions of the main blockchain. Multiple child chains can be placed on top of each other in a tree-like manner and only need to interact with the main chain periodically. Moreover, plasma works in a similar way to sidechains. However, plasma requires less initial capital.

Layer-2 Projects

An increasing number of projects are rushing to assist the scaling operation underway on the Ethereum blockchain. So, now that you’re familiar with layer-2 scaling solutions, let’s take a closer look at some of the most prominent layer-2 solutions on Ethereum.

Polygon

Polygon is an all-in-one Ethereum scaling solution with several product offerings. This includes Polygon PoS, an EVM-compatible permissionless sidechain, Polygon Hermez, an open-source zk-rollup solution, and Polygon Nightfall, an optimistic rollup service. Also, Polygon features a STARK-based rollup for smart contracts and a modular framework for building Ethereum-compatible blockchain networks.

Loopring

Loopring is a trustless Ethereum scaling solution, non-custodial exchange, and payment protocol that shares the same security as Ethereum. It uses zk-rollups to batch process thousands of computations away from the main Ethereum blockchain, preventing congestion. Furthermore, Loopring minimizes gas consumption and passes on the savings to users.

Immutable X

Immutable X is a zk-rollup and non-fungible token (NFT) exchange on StarkWare and the first NFT layer-2 solution for Ethereum. The project aims to make play-to-earn (P2E) gaming more accessible and rewarding while ensuring the same levels of transparency and security as the Ethereum blockchain.

StarkWare

StarkWare is an Ethereum scaling solution with two product offerings. First, StarkNet is a permissionless, Ethereum Virtual Machine (EVM)-compatible zk-rollup that enables developers to deploy scalable decentralized applications (dApps). Second, StarkEx is a software as a service (SaaS) provider that offers NFT minting, trading, derivatives, and DeFi templates.

Consider layer-1 vs layer-2 when wanting blockchain scaling solutions

Arbitrum

Arbitrum is an Ethereum layer-2 scaling solution that uses rollup technology. It enables developers to run Ethereum Virtual Machine (EVM) smart contracts on a separate layer with low fees while retaining the same security of the main Ethereum chain. Accordingly, Arbitrum is host to an array of layer-2 dApps.

zkSync

Another iteration of zk-rollup technology is zkSync, which helps to reduce congestion, speed up transactions, and minimize transaction fees on layer-1 blockchains by taking the majority of computations off-chain. Thanks to the use of zk-rollups, zkSync benefits from the security of the Ethereum blockchain.

The Bitcoin Lightning Network

When most people think of layer-2 scaling solutions, they tend to think of Ethereum. Lightning Network, however, is helping to optimize transactions on the Bitcoin blockchain to help it gain adoption as a payments processor.

The Bitcoin asset and lightning strikes depicting the "Lightning Network" solution

As the Bitcoin blockchain can only process up to seven transactions per second (TPS), it isn’t capable of handling global commerce. However, Lightning Network aims to solve this by taking heavy computations off-chain and putting them back on-chain at a later stage.

Layer-1 vs Layer-2

Layer-1 scaling solutions are great if they were a part of the initial vision for a particular project. However, implementing them once the network has grown poses challenges. Layer-2 solutions enable multiple development teams to create innovative tools that work in harmony without changing the underlying architecture of a layer-1 blockchain. Accordingly, layer-2 scaling solutions appear to be a prominent feature in the rollout of Ethereum 2.0

Blockchain: Layer-1 vs Layer-2 – Summary 

Layer-2 solutions help to alleviate congestion on layer-1 blockchains by taking computations off the main chain and optimizing gas fees. In addition, layer-1 scaling solutions make improvements to the underlying protocol of a blockchain to achieve the same thing. 

Blockchains different layers to consider when addressing layer-1 vs layer-2

This is important if blockchain and cryptocurrency are to achieve mass adoption because blockchain networks will need to compete with global payments giants such as PayPal and Visa. However, thanks to layer-2 solutions, developers can create complex financial applications that are simple and inexpensive to use.

After reading this “Layer-1 vs Layer-2” article, you should be able to discuss the different ways to scale a blockchain confidently. If you want to learn how to build your own decentralized applications (dApps), check out the Ethereum dApp Programming course at Moralis Academy. This course teaches students everything they need to know to build their own dApps on Ethereum. 

Also, if you have zero coding experience, be sure to check out the JavaScript Programming for Blockchain Developers course to learn the basics. Regardless of experience, we have the perfect courses for you. Become blockchain certified with Moralis Academy!

Don’t forget to follow us on Twitter @MoralisAcademy! We’d love to hear your thoughts about layer-1 vs layer-2 blockchain solutions! In addition, check out ourWhat is Phantom Wallet?” and “Most Expensive NFTs Sold” articles to expand your blockchain and Web3 knowledge further!