By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
A blockchain bridge is a set‑of‑smart‑contracts and off‑chain relayers that let assets (ERC‑20, ERC‑721, state) move between two otherwise isolated chains. By “bridging” Ethereum to Layer‑2s such as Polygon, Arbitrum, Optimism, or zkSync, users can keep the security of the Ethereum mainnet while enjoying cheap, fast transactions on the L2. Real‑world: a DeFi trader swaps ETH for USDC on Uniswap (Ethereum), bridges the USDC to Polygon, and then supplies it to a lending pool that offers 10× lower gas fees.
Bridge Contract (Lock‑Mint pattern): The source chain contract locks the original token, while the destination chain contract mints a wrapped representation (e.g., PolygonUSDC). solidity // Source (Ethereum) – lock function lock(address token, uint256 amount) external { IERC20(token).transferFrom(msg.sender, address(this), amount); emit Locked(msg.sender, token, amount); }
PolygonUSDC
solidity // Source (Ethereum) – lock function lock(address token, uint256 amount) external { IERC20(token).transferFrom(msg.sender, address(this), amount); emit Locked(msg.sender, token, amount); }
Message Passing (L2 → L1): A system where the L2 posts a calldata‑packed message to an L1 inbox; the L1 contract executes it after a challenge period. solidity // Optimism L2 → L1 IOptimismInbox(inbox).sendMessage(l1Target, calldata, gasLimit);
solidity // Optimism L2 → L1 IOptimismInbox(inbox).sendMessage(l1Target, calldata, gasLimit);
Optimistic Rollup: Assumes blocks are valid unless a fraud proof is submitted. Faster & cheaper, but finality is delayed (usually 1‑7 days).
RootChainManager
ChildChainManagerProxy
bridgeMint
bridgeBurn
solidity function bridgeMint(address to, uint256 amount) external onlyBridge { _mint(to, amount); }
npx hardhat compile && npx hardhat test
js const Bridge = await ethers.getContractFactory("EthBridge"); const bridge = await Bridge.deploy(); await bridge.deployed();
setFxRootTunnel
ERC20
bridgeMint/burn
js await bridge.lock(USDC_ADDRESS, ethers.utils.parseUnits("100", 6)); // Watch the `Locked` event, then call `bridgeMint` on the L2 side.
@maticnetwork/maticjs
wagmi
(For Arbitrum, Optimism, or zkSync replace steps 4‑6 with the respective SDKs: @arbitrum/sdk, @eth-optimism/sdk, @zksync/web3.)
@arbitrum/sdk
@eth-optimism/sdk
@zksync/web3
Mistake: Approving the L1 token but forgetting to approve the L2 wrapper. Correction: Always call approve on the L2 bridge contract after the first deposit; otherwise bridgeMint will revert.
approve
Mistake: Assuming instant finality after a L2→L1 message. Correction: Respect the challenge period (Optimism ≈ 7 days, Arbitrum ≈ 1 day). UI should show “Pending finalization” until the period ends.
Mistake: Hard‑coding mainnet addresses when testing on testnets. Correction: Use environment variables (process.env.POLYGON_BRIDGE) and separate config files for each network.
process.env.POLYGON_BRIDGE
Mistake: Relying on tx.origin for access control in bridge contracts. Correction: Use msg.sender and role‑based AccessControl – tx.origin can be spoofed through a malicious contract.
tx.origin
msg.sender
AccessControl
Mistake: Skipping the “withdrawal proof” step on Polygon (i.e., not submitting the Merkle proof). Correction: Call exit on the RootChainManager with the correct proof; otherwise funds stay locked forever.
exit
Scenario: A dApp lets users bridge ERC‑20 tokens from Ethereum to Arbitrum, but the UI immediately shows the new balance on Arbitrum after the transaction is mined on L1. Answer: Wrong – Arbitrum’s L2 state isn’t final until the retryable ticket is executed; the UI should wait for the L2 receipt.
Scenario: A bridge contract uses tx.origin == owner to restrict who can call bridgeMint. Answer: Dangerous – a malicious contract can forward a user’s transaction, making tx.origin the user while msg.sender is the attacker; use msg.sender with proper role checks.
tx.origin == owner
Scenario: You need to withdraw USDC from zkSync to Ethereum. Which component must you interact with? Answer: The zkSync L2→L1 exit contract that verifies the zk‑proof and releases the locked token on Ethereum.
uint256
uint128
pragma solidity ^0.8.17
tokensReceived
ticketStatus
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.