Layer 2 Solutions Explained: Complete Guide

Rollups, sidechains, and the quest for scale. Learn how Ethereum extends without sacrificing security.

Intermediate 35 min read

🎯 What You'll Learn

  • Understand why Layer 2 exists
  • Learn the different L2 approaches
  • Know optimistic vs ZK rollups
  • Compare L2 security models
  • Choose the right L2 for your use case

📚 Prerequisites

Before this lesson, you should understand:

The Scaling Problem

Ethereum processes ~30 transactions per second. Visa does ~65,000. To achieve mass adoption, blockchains must scale.

Layer 2 solutions process transactions off the main chain while inheriting its security.


Layer 1 vs Layer 2

Layer 1 (Ethereum)Layer 2
SecurityDirectDerived from L1
Speed~30 TPS1,000-10,000+ TPS
Cost$5-50/tx$0.01-0.50/tx
Finality~15 minSeconds (soft) → L1 (hard)
L2 Transactions
Fast, cheap
Batch & Compress Post to L1
Final security

Types of Layer 2

1. Rollups

Rollups bundle transactions and post data to L1:

TypeProofFinality
OptimisticFraud proofs (challenge period)~7 days
ZKValidity proofs (cryptographic)Minutes to hours

2. State Channels

Direct peer-to-peer channels:

  • Fast for repeated interactions
  • Limited to participants
  • Example: Lightning Network

3. Sidechains

Separate chain with own consensus:

  • Fast and cheap
  • Less secure (own validator set)
  • Example: Polygon PoS

4. Validium

ZK proofs but data stored off-chain:

  • Very cheap
  • Data availability risk
  • Example: StarkEx

Optimistic Rollups

Assume transactions are valid, allow challenges.

Transactions Sequencer batches Post to L1 7 day challenge Finalized

Challenge period: Anyone can submit fraud proof if batch is invalid.

RollupStatusTVL
ArbitrumLive$8B+
OptimismLive$5B+
BaseLive$2B+

Pros & Cons

ProsCons
EVM compatibleLong withdrawal time (7 days)
Mature technologyFraud proof game theory
High throughputCentralized sequencer (current)

ZK Rollups

Prove validity using zero-knowledge proofs.

Transactions Generate ZK proof Post proof + data to L1 Verified & Final
RollupStatusEVM?
zkSync EraLiveYes
StarkNetLiveNo (Cairo)
Polygon zkEVMLiveYes
ScrollLiveYes

Pros & Cons

ProsCons
Fast finalityComplex technology
Cryptographic securityExpensive proof generation
Faster withdrawalsLess mature

Security Comparison

SolutionSecurity ModelData Availability
Optimistic RollupL1 + fraud proofsOn L1 (calldata)
ZK RollupL1 + validity proofsOn L1
ValidiumValidity proofsOff-chain
SidechainOwn consensusOwn chain

Key insight: Rollups inherit L1 security. Sidechains don’t.


Using Layer 2

Bridging Assets

1. Connect wallet to bridge
2. Deposit ETH/tokens on L1
3. Wait for confirmation
4. Assets available on L2

Important: Each L2 has its own bridge. Withdrawals may take time (especially optimistic rollups).

Gas on L2

L2s still use gas, but much cheaper:

OperationEthereumArbitrum
ETH transfer$2-10$0.01-0.05
Swap$20-100$0.10-0.50
NFT mint$30-150$0.20-1.00

Practice Exercises

Exercise 1: Calculate Savings (Beginner)

You do 100 swaps/month.

  • Ethereum: $30/swap
  • Arbitrum: $0.30/swap

Monthly savings?

Answer

Ethereum: 100 × 30=30 = 3,000 Arbitrum: 100 × 0.30=0.30 = 30 Savings: $2,970/month

Exercise 2: Security Analysis (Intermediate)

Compare withdrawing from:

  • Arbitrum (optimistic rollup)
  • zkSync (ZK rollup)
  • Polygon PoS (sidechain)

What are the risks and timeframes?

Answer
  • Arbitrum: 7 day dispute period, but L1 secured
  • zkSync: Fast (hours), proof verified on L1
  • Polygon PoS: Fast, but own validator set-bridge exploits possible

Exercise 3: Design Question (Advanced)

Why do optimistic rollups have a 7-day challenge period? What would happen with 1 day?


Knowledge Check

  1. What problem does Layer 2 solve?

  2. What’s the difference between optimistic and ZK rollups?

  3. Why are sidechains less secure than rollups?

  4. What is the 7-day challenge period for?

  5. Where is transaction data stored in rollups?

Answers
  1. Scalability. L1 can’t handle enough transactions cheaply. L2 processes off-chain, posts proofs to L1.

  2. Optimistic assumes valid, allows fraud challenges. ZK proves validity cryptographically-faster finality.

  3. Own consensus. Sidechains don’t inherit L1 security. Rollups post data/proofs to L1.

  4. Fraud proof window. Anyone can challenge an invalid batch. After 7 days, it’s finalized.

  5. On Layer 1 (as calldata). This ensures data availability-anyone can reconstruct state.


Summary

L2 TypeSecurityFinalityEVM
Optimistic RollupL1 inherited7 daysYes
ZK RollupL1 inheritedHoursVaries
SidechainOwn validatorsFastYes

What’s Next?

🎯 Continue learning:


You now understand how Ethereum scales without sacrificing security. 🚀

Questions about this lesson? Working on related infrastructure?

Let's discuss