But First, What Is Blockchain?
Blockchain is a fundamental concept in understanding the way cryptocurrency works. But it’s not only limited to its application in crypto.
The blockchain is a database that stores information from transactional records in a universal ledger. Assets are traded and tracked on the blockchain, reducing risk and cutting costs for everyone involved.
Blockchain allows you to send money to a friend in seconds without worrying about banking fees and other charges. You can also store cash in an online wallet and don’t need anyone’s permission to move it or transfer ownership.
Every block on the blockchain has a specific number of transactions. When a new block generates on-chain, it’s added to each network node’s ledger and uses distributed ledger technology (DLT).
A key concept of blockchain is that it’s decentralized, which allows for transparency and real-time access to assets. Being decentralized also enables the network participants to be collectively responsible for the security, as opposed to having a centralized entity like a bank or governing body.
Other fundamentals of blockchain technology include being immutable and distributed. Since the ledger is immutable, you can always trust that the information is accurate because no one can alter it.
Since the blockchain is also distributed, it potentially protects users from network attacks and other instances of fraud and cybersecurity threats.
Layer 1 vs. Layer 2: What are The differences
Layer 1 is the main blockchain network in charge of on-chain transactions, while Layer 2 is the connected network in charge of off-chain transactions
What are layer 2 solutions?
Layer 2 is a term used for solutions created to help scale an application by processing transactions off of the Ethereum Mainnet (layer 1) while still maintaining the same security measures and decentralization as the mainnet. Layer 2 solutions increase throughput (transaction speed) and reduce gas fees. Popular examples of Ethereum layer 2 solutions include Immutable X, Polygon, and Polkadot.
Why are layer 2 solutions important?
Layer 2 solutions are important because they allow for scalability and increased throughput while still holding the integrity of the Ethereum blockchain, allowing for complete decentralization, transparency, and security while also reducing the carbon footprint (less gas, means less energy used, which equates to less carbon.)
Although the Ethereum blockchain is the most widely used blockchain and arguably the most secure, that doesn’t mean it doesn’t come with some shortcomings. The Ethereum Mainnet is known to have slow transaction times (13 transactions per second) and expensive gas fees. Layer 2s are built on top of the Ethereum blockchain, keeping transactions secure, speedy, and scalable.
Each individual solution has its own pros and cons to consider such as throughput, gas fees, security, scalability, and of course functionality. No single layer 2 solution currently fulfills all these needs. However, there are layer 2 scaling solutions that aim to improve all these aspects; these solutions are called rollups.
What are layer 2 rollups?
Rollups are layer 2 scaling solutions that perform transaction operations off the main Ethereum blockchain, but still post the transaction data onto layer 1. Considering the transaction data is on layer 1, rollups are secured by the same layer 1 security measures. In fact, this is the defining feature that rollups offer to users.
There are three properties of a layer 2 rollup:
- Transactions are executed outside of layer 1 (reduces gas fees)
- Data and proof of transactions reside on layer 1 (maintains security)
- A rollup smart contract which is found on layer 1, can enforce proper transaction execution on layer 2, by using the transaction data that is stored on layer 1
Ultimately, rollups require users like you and me to stake a bond in the rollup smart contract, which encourages users to verify and execute transactions correctly.
Rollups are useful because they reduce fees, increase transaction throughput, and expand participation. There are two kinds of rollups with different security measures:
- Optimistic rollups assume transactions are valid by default and only runs computation, via a fraud proof, in the act of a challenge
- Zero-knowledge rollups runs computation off-chain and submits a validity proof to the main-chain
Optimistic rollups sit in parallel to the Ethereum Mainnet on layer 2 and don’t perform any computation (mathematical equations) by default. Instead, after the transaction is complete, they submit the new state to the Ethereum Mainnet, essentially notarizing the transaction.
Optimistic rollup transactions are written into the main Ethereum blockchain, further optimizing transactions by reducing the cost of gas.
Advantages of optimistic rollups include:
- Low gas fees
- Increased throughput
- Smart contract capability
- Security (guaranteed by the Ethereum Mainnet)
Disadvantages of optimistic rollups:
- Long withdrawal time (challenge periods can last for weeks)
- If a fraudulent transaction is discovered, the rollup will automatically call a fraud-proof and run the transaction’s computation using the available written data, leading to long withdrawal times if the transaction is challenged.
There are several applications of optimistic rollups that you can integrate into your own dapps:
Zero-knowledge rollups (ZK rollups) bundle thousands of transactions off the main Ethereum chain and create cryptographic proof which is known simply as SNARK (succinct non-interactive argument of knowledge). This is called validity proof, which is posted to the Ethereum Mainnet.
The smart contract for a ZK rollup keeps the data of all transfers on layer 2 and the data can only be edited with a validity proof. Meaning, ZK rollups only need validity proof, opposed to all the transaction data. This function decreases the cost to transact due to less data being included.
When it comes to ZK rollups, there is minimal hesitation when moving assets from layer 2 to layer 1, considering the validity proof has already been approved by the ZK rollup and has already authorized the transaction.
Advantages of ZK rollups include:
- Near instant transfers
- Not vulnerable to the attacks that optimistic rollups may be affected by
- Still secure and decentralized
Disadvantages of ZK rollups:
- Validity proofs are extreme to compute for smaller applications with less on-chain activity
- A user can influence transaction ordering
- Some rollups don’t offer Ethereum Virtual Machine (EVM) support
There are numerous applications of ZK rollups that you can integrate into your own dapps:
Ethereum layer 2 solutions have some serious potential to change the blockchain landscape for the better. Layer 2 solutions ensure that users are able to maintain all the safety measures used on the Ethereum Mainnet while still being able to transact quickly and at little to no cost for users.
This type of technology may encourage more people to try out the Ethereum blockchain and everything it has to offer. Also, keep in mind that many layer 2 solutions are still in their beta phase, meaning you should research everything in-depth and always remain curious and cautious when exploring the various layer 2 solutions.