Back to blog

Blockchain Basics, part three: Layer 2 Solutions

Blockchain Basics, part three. Layer 2 Solutions.

The concepts behind Optimism, Bitcoin Lightning, and Polygon(Matic).

(Thank you to everyone who has taken the time to read this series so far, I hope it’s making blockchain a little easier to digest!)

Photo by Fakurian design on Unsplash

Before we dive into today’s article, we have a new discord server where the bitgrit community discusses all things data science and AI, including our newly released BGR token! Join the server here!

Introduction

We’ve talked about some of the amazing features that cryptocurrencies like Ethereum have available but there’s been a cost to all this activity on-chain: rising gas fees (transaction fees). Ethereum processes around 12 transactions a second, which although slow, is intended by design. The security of Proof-of-Work (PoW) systems relies on problems that require computational power and time to solve, else they become vulnerable to exploitation.

So if low transaction times are a fundamental aspect of PoW blockchains, what can be done to increase scalability?

Layer 2 Solutions

One answer to this question, and the most popular one is the adoption of Layer 2 solutions. Layer 2 sits on top of Layer 1, or the main chain. The idea behind them is quite simple: process transactions outside of Ethereum and send only the results onto the main chain itself. The implementation of this concept has been interpreted in 3 different ways, payment channels, sidechains, and rollups.

Payment Channels
Payment channels connect two parties together, allowing them to amend a pending transaction between them. There are only two transactions made to Ethereum during this process; when the channel is opened and when it’s closed.

To illustrate the use of payment channels, take something you pay for on a routine basis, such as transportation fare or your rent. These could all be paid for with fewer fees by using a payment channel over main-net Ethereum (L1). You’ll be able to use ETH to pay without the fees after setting up the initial channel and the balance will be reflected on the main chain once the channel closes. However, there are quite a few trade-offs. Payment channels require a deposit that will have to cover all of the transactions you plan to make. It’s very similar in concept to the way prepaid cards work. You’ll also have to keep opening and closing channels when you want to transfer your funds back to L1, which is time-consuming to do and ties you up during the process. Payment channels also don’t support NFTs.
Both you and the other party also need to be online for transactions to go through which can cause transactions to fail.
A popular example of a payment channel being used today is Bitcoin Lightning.

Sidechains
Sidechains are entirely new blockchains that mimic the main chain and use a two-way peg to “transfer” assets between chains. Users lock up their assets on L1, which are then created on the side-chain for use. To withdraw, the L2 asset is burnt and the L1 asset is released. The whole process is validated by a separate group of nodes that monitor both chains and cancel any fraudulent transactions. An example of a popular side chain is Polygon (Matic) for Ethereum. Sidechains rely on you to trust their security and due to only having a few nodes, are considered a very centralized solution.

Rollups
As the name suggests, transactions are processed, batched together (rolled up), and compressed separately from the main chain. This allows you to do everything you would do on Ethereum, including minting NFTs. However, transferring these to L1 takes up to a week due to fraud checks, making it inconvenient for some. It also involves minting the NFT on both layers, the layer 2 version representing an NFT IOU (I owe you). Tokens can also be deployed on rollups. A popular rollup solution on Ethereum is Optimism.

Summary

Every layer 2 solution has its own disadvantages, as they have to work around Ethereum’s very rigid framework which is built around security, not speed. The most important thing to understand about layer 2 assets is that they are all essentially IOUs for the underlying assets on Ethereum main-net. For all their disadvantages, they do solve the problem of transaction costs and transaction speed however and I predict that each of these solutions will see use in various ways in the future.


Liked this article? Catch up with parts one and two!

Be sure to also follow our social media pages to stay updated on talks and upcoming competitions!