Layer-2 refers to a network or technology that operates on top of an underlying blockchain protocol to improve its scalability and efficiency. This category of scaling solutions entails shifting a portion of a blockchain protocol’s transactional burden to an adjacent system architecture, which then handles the brunt of the network’s processing and only subsequently reports back to the main blockchain to finalize its results. By abstracting the majority of data processing to auxiliary architecture, the base layer blockchain becomes less congested — and ultimately more scalable.
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 which aim to improve all these aspects; these solutions are called rollups.
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:

