By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Layer 2 solutions are protocols that sit on top of the Ethereum base layer (L1) to move most of the work off‑chain while still inheriting its security guarantees. By batching many transactions into a single proof or by posting them to a separate chain, they cut fees dramatically and boost throughput, making everyday DeFi actions—like a Uniswap swap, an NFT mint, or a DAO vote—feel instant and cheap.
L2_Sequencer
BatchVerifier
```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.24;
contract L1Bridge { event Locked(address indexed token, address indexed sender, uint256 amount, bytes32 indexed l2Recipient); function lock(address token, uint256 amount, bytes32 l2Recipient) external { IERC20(token).transferFrom(msg.sender, address(this), amount); emit Locked(token, msg.sender, amount, l2Recipient); } } ```
js // hardhat script – submit a batch to Optimism’s L1 contract const { ethers } = require("hardhat"); async function main() { const batch = ethers.utils.defaultAbiCoder.encode( ["bytes[]"], [signedTxs] ); const verifier = await ethers.getContractAt("OptimismVerifier", L1_VERIFIER); const tx = await verifier.submitBatch(batch); await tx.wait(); console.log("Batch submitted, hash:", tx.hash); } main();
selfdestruct
blockhash
@eth-optimism/plugins
zksync-dev
solidity: { version: "0.8.24", settings: { optimizer: { enabled: true, runs: 200 }}}
https://goerli.optimism.io
https://testnet.zksync.io
js const provider = new ethers.JsonRpcProvider(L2_RPC); const wallet = new ethers.Wallet(PRIVATE_KEY, provider); const factory = new ethers.ContractFactory(abi, bytecode, wallet); const l2Contract = await factory.deploy(); await l2Contract.waitForDeployment(); console.log("Deployed to L2 at", await l2Contract.getAddress());
mint
wagmi
ethers
BatchSubmitted
ChallengeResolved
Mistake: Assuming L2 gas costs are the same as L1. Correction: Always query the L2 gas‑price oracle; L2 gas is cheaper per unit but the total cost depends on batch size and proof verification.
Mistake: Hard‑coding block.timestamp for time‑sensitive logic. Correction: Rollups may reorder batches, so use block.number or a deterministic epoch supplied by the rollup’s L2Block contract.
block.timestamp
block.number
L2Block
Mistake: Forgetting to enable data availability when using a sidechain. Correction: Choose a sidechain that publishes calldata on L1 (e.g., Polygon’s PoS bridge) or run a DA service like Celestia; otherwise users cannot challenge fraudulent state.
Mistake: Deploying a contract that relies on tx.origin for auth. Correction: Use msg.sender and role‑based access (OpenZeppelin AccessControl) because rollup batches can be relayed by a sequencer, breaking tx.origin expectations.
tx.origin
msg.sender
AccessControl
Mistake: Ignoring the challenge window (e.g., 7 days on Optimism). Correction: Build UI alerts that warn users when a batch is still under dispute; premature withdrawals can be reverted by a successful fraud proof.
call
delegatecall
hooks
nonce
Scenario: A user submits a transaction to an Optimistic rollup, but the sequencer is offline for 2 days. What happens to the user’s transaction? Answer: It stays in the mempool until the sequencer resumes; the rollup’s challenge window only starts after the batch is posted, so the user’s tx isn’t at risk of being censored permanently.
Scenario: Your L2 contract uses block.timestamp to enforce a 24‑hour voting period. A batch is delayed by 6 hours. Does the voting period extend automatically? Answer: No. block.timestamp reflects the block’s time, not real‑world elapsed time; delayed batches shorten the effective voting window, so you should base periods on batch numbers or a rollup‑provided epoch.
Scenario: You lock 100 USDC on L1 and receive 100 USDC on a ZK‑Rollup, but later the proof verification fails. What is the state of the L1 lock? Answer: The L1 lock remains unreleased (still held by the bridge) because the rollup batch was rejected; users can retry the bridge after the issue is resolved.
unchecked {}
lock → emit event → L2 listener → mint
SELFDESTRUCT
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.