What Is Layer 2, and How Does It Work?
Layer 2 is a system that runs on top of a main blockchain to make transactions faster and cheaper. Here is how it works, the main types, and when to use one.
On this page
Short answer
Layer 2 is a system built on top of a main blockchain, called layer 1, that handles transactions away from the main chain and then records the result back on it. It exists because the main chain can only process a limited number of transactions at once, so moving the work elsewhere makes payments faster and cheaper while the main chain still provides the security.
What is layer 2?
Layer 2 is a system that runs on top of a main blockchain and handles transactions away from the main chain, then records the result back on the main chain. The main chain, called layer 1, stays in charge of security and the final record, while layer 2 does the heavy work of processing many small transactions.
Think of it as a fast lane next to a busy road. The main road is safe but slow, because every car must stop at every checkpoint. The fast lane lets the cars through quickly and sends a single summary to the main road, so the road only has to check one record instead of thousands of cars.
Layer 2 is not a separate blockchain in the usual sense. It depends on layer 1 for its security: if the main chain is safe, the layer 2 record is safe too. For the Bitcoin version of the same idea, what is Bitcoin layer 2 explains how the Lightning Network works on top of Bitcoin.
Why do blockchains need layer 2?
Blockchains need layer 2 because the main chain can only process a limited number of transactions in each block, and every transaction on it competes for the same space. When demand rises, fees rise and waits get longer, which makes small payments impractical.
The table below shows what each layer does and why the split helps.
| Job | Layer 1 (main chain) | Layer 2 |
|---|---|---|
| Security | Holds the final record | Relies on layer 1 |
| Speed | Slow, every node checks all | Fast, few parties check |
| Fees | High when busy | Low, costs shared |
| Capacity | Fixed per block | Much higher |
| Best for | Large, final settlement | Everyday payments |
Without layer 2, a popular blockchain app would have to pay main-chain fees for every click, tap or trade. With layer 2, hundreds of those actions are bundled into one main-chain record, so each user pays a small share of one fee instead of a whole fee each.
How do optimistic rollups work?
An optimistic rollup is a layer 2 design that bundles many transactions together, assumes they are correct, and posts the bundle to the main chain for anyone to check. The word optimistic describes the assumption: the bundle is accepted unless someone proves it wrong.
After a bundle is posted, there is a challenge period, usually about a week, during which anyone can submit proof that a transaction was wrong. If the proof holds, the wrong transaction is removed and the party that posted it loses a bond they put up in advance. That bond is what keeps posters honest.
The trade-off is the wait. A user who wants to move funds back to the main chain must wait for the challenge period to end, because the bundle is only final once nobody has challenged it. That wait is the main cost of the design, and it is why optimistic rollups suit apps where users do not need instant withdrawals.
How do ZK rollups work?
A ZK rollup is a layer 2 design that bundles many transactions together and posts a short cryptographic proof to the main chain, showing that the bundle is correct. The main chain checks the proof instead of checking every transaction, which takes far less work.
The proof is the key difference from an optimistic rollup. There is no challenge period, because the proof itself shows the bundle is valid, so funds can move back to the main chain as soon as the proof is checked. That makes ZK rollups faster to exit, at the cost of harder maths to build the proof in the first place.
ZK rollups are now used for payments, trading and identity apps, and they are the design most new layer 2 projects choose when they need fast finality. For a direct comparison of the two rollup designs, ZK rollups vs optimistic rollups sets out the differences side by side.
What other layer 2 designs exist?
Rollups are the most common layer 2 design today, but three older designs are still in use, and each one fits a different job.
- State channels. Two parties open a channel, transact between themselves as often as they like, and only record the opening and closing on the main chain. They suit repeated payments between the same two parties.
- Sidechains. A separate chain that runs next to the main chain with its own validators and its own security. It is fast, but it does not inherit the main chain's security, so it is really a separate chain with a bridge.
- Validium. Like a ZK rollup, but the transaction data is kept off the main chain to cut costs further. The trade-off is that users must trust whoever holds the data.
For most teams building today, the choice is between the two rollup types. State channels are narrow, sidechains are a different security model, and validium trades transparency for cost. A list of the networks that use these designs is in top layer 2 blockchains.
Example (hypothetical): a payments app moves to layer 2
Picture a payments app with 10,000 users who each make one small payment a day. On the main chain, each payment costs $2 in fees, so the app pays $20,000 a day in fees, which is more than the payments are worth.
The app moves to a ZK rollup. The rollup bundles the 10,000 payments into one main-chain record that costs $500, plus $0.05 per payment for the rollup's own processing, which is another $500. The total is $1,000 a day, or $0.10 per payment, instead of $2.
The app saves $19,000 a day, and the user experience changes from a payment that takes minutes to one that takes seconds. The main chain still holds the final record, so the security is the same, and the only new cost is the rollup's own fee.
What are the common mistakes?
The most common mistakes when choosing a layer 2 are picking a design for its marketing, ignoring the exit time, and assuming every chain needs one.
- Picking by hype. A rollup with a large following may not fit your app. Check the fees, the exit time and the tooling before choosing.
- Ignoring the exit time. An optimistic rollup takes about a week to move funds back to the main chain. If your users need their money back fast, that wait matters.
- Assuming layer 2 fixes everything. Layer 2 makes transactions cheaper and faster, but it does not fix a bad product, a weak market or a broken business model.
- Forgetting the bridge. Moving funds between layer 1 and layer 2 needs a bridge, and bridges are a common target for attackers. Use a well-tested one.
- Treating a sidechain as layer 2. A sidechain has its own validators and its own security, so it is not as safe as a rollup that inherits the main chain's security.
For the chain behind most rollups, what is a ZK rollup explains the proof design in more detail.
Key takeaways
- Layer 2 handles transactions off the main chain and records the result back on it
- Optimistic rollups assume bundles are correct and allow a week-long challenge period
- ZK rollups post a proof of correctness, so funds can exit as soon as it is checked
- State channels, sidechains and validium fit narrower jobs than rollups
- Test the exit path and the bridge before building on a layer 2
Frequently asked questions
What is the difference between layer 1 and layer 2?
Layer 1 is the main blockchain, which holds the final record and provides the security. Layer 2 is a system built on top of it that handles transactions away from the main chain and records the result back, so the work is faster and cheaper.
Is layer 2 as safe as layer 1?
A rollup inherits the main chain's security, because the main chain checks the bundle or the proof. A sidechain does not, because it has its own validators, so it is less safe than a true layer 2 rollup.
Why do optimistic rollups take a week to withdraw?
After a bundle is posted, anyone has about a week to submit proof that a transaction was wrong. The withdrawal must wait for that period to end, because the bundle is only final once nobody has challenged it.
What is the cheapest layer 2 design?
The cheapest design depends on the job, because fees change with demand. ZK rollups usually have low per-transaction costs and fast exits, while optimistic rollups are simpler to build on. Check the current fees on the network you plan to use.
Do I need layer 2 for a small app?
Probably not. If your app handles a few hundred transactions a day, the main chain may be fine. Layer 2 pays off when the volume is high enough that main-chain fees would eat the margins.
Can a layer 2 fail?
Yes, if its operator stops, its bridge is attacked, or its proof system has a bug. The funds on the main chain are still safe, but moving them back can take time. Use a well-tested design and a well-tested bridge.