Optimism is an Optimistic Rollup solution that enables significantly lower transaction costs compared to the Ethereum Mainnet (Layer 1 or L1). While transactions are processed by a limited number of nodes rather than every network participant, all data gets written to L1. This approach maintains the full security guarantees and data availability of Ethereum Mainnet while reducing costs.
To utilize L1 assets on Optimism (or any Layer 2 solution), users must bridge their assets. The standard process involves locking assets (typically ETH or ERC-20 tokens) on L1 and receiving equivalent assets on L2. When users want to return assets to L1, the L2 assets get burned, and the original L1 assets get released back to the user.
How the Optimism Standard Bridge Works
The Optimism Standard Bridge facilitates asset transfers between Ethereum Mainnet and Optimism through two primary workflows:
- Deposit flow: Moving assets from L1 to L2
- Withdrawal flow: Moving assets from L2 to L1
Deposit Flow Process
Layer 1 Operations
- For ERC-20 deposits, the user grants the bridge contract allowance to spend the specified token amount
- The user calls the appropriate L1 bridge function (
depositERC20,depositERC20To,depositETH, ordepositETHTo) The L1 bridge takes custody of the assets:
- ETH: Transferred as part of the transaction value
- ERC-20: Transferred using the allowance mechanism
- The L1 bridge uses Optimism's cross-domain messaging to call
finalizeDepositon the L2 bridge
Layer 2 Operations
The L2 bridge verifies the
finalizeDepositcall authenticity:- Confirms it originated from the cross-domain messenger contract
- Validates it came from the legitimate L1 bridge
The L2 bridge checks whether the ERC-20 token contract on L2 matches expectations:
- The L2 contract reports its L1 counterpart matches the source token address
- The L2 contract supports the required interface (verified via ERC-165)
- If validation passes, the L2 bridge mints tokens to the recipient address. If validation fails, it initiates a withdrawal process to return tokens to L1
Withdrawal Flow Process
Layer 2 Operations
- The user calls the L2 bridge (
withdraworwithdrawTo) - The L2 bridge burns the specified amount of tokens from the user's balance
- The L2 bridge uses cross-domain messaging to call
finalizeETHWithdrawalorfinalizeERC20Withdrawalon the L1 bridge
Layer 1 Operations
The L1 bridge verifies the finalization call legitimacy:
- Confirms it came through the cross-domain messenger
- Validates it originated from the legitimate L2 bridge
- The L1 bridge transfers the appropriate asset (ETH or ERC-20) to the designated recipient
👉 Explore advanced bridging strategies
Layer 1 Contract Architecture
The L1 bridge components operate on Ethereum Mainnet and include several key interfaces and implementations.
Core Interfaces
IL1ERC20Bridge Interface
This interface defines the functions and events required for ERC-20 token bridging, including deposit initiation and withdrawal finalization events. The interface uses Solidity version pragmas that maintain compatibility across multiple compiler versions.
IL1StandardBridge Interface
This interface extends IL1ERC20Bridge to include ETH-specific functionality. The separation allows custom bridges to handle specialized ERC-20 tokens without implementing ETH bridging capabilities.
Cross-Domain Messaging Foundation
The CrossDomainEnabled contract provides the foundational messaging capabilities for both L1 and L2 bridges. It includes:
- Authentication modifiers to verify cross-domain message sources
- Message sending functionality through the cross-domain messenger
- Security checks to ensure only authorized contracts can trigger cross-domain operations
L1 Standard Bridge Implementation
The main L1 bridge contract implements both standard bridge interfaces and inherits from CrossDomainEnabled. Key features include:
- Initialization pattern: Uses a proxy architecture for upgradability without storage migration
- EOA restrictions: Certain functions limited to externally-owned accounts for security
- Asset handling: Differentiates between ETH and ERC-20 token processing
- Deposit tracking: Maintains mapping of L1 to L2 token deposits
- Security measures: Includes extensive validation checks for all cross-domain operations
The contract uses OpenZeppelin's SafeERC20 library for secure token transfers and includes emergency functions like donateETH for managing contract upgrades and asset migrations.
ERC-20 Token Implementation on L2
For seamless integration with the standard bridge, L2 ERC-20 tokens must implement specific functionality beyond the standard interface.
IL2StandardERC20 Interface
This interface extends standard ERC-20 functionality with:
l1Token()function to identify the corresponding L1 tokenmint()andburn()functions for token creation and destruction- ERC-165 interface support for standardized contract detection
- Custom events for minting and burning operations
L2StandardERC20 Implementation
The reference implementation provides:
- Access control: Minting and burning restricted to the L2 bridge
- ERC-165 compliance: Proper interface detection support
- Integration readiness: Standardized pattern for bridge-compatible tokens
- Security: Inherits from audited OpenZeppelin ERC-20 implementation
Layer 2 Bridge Implementation
The L2 bridge mirrors the L1 functionality but with reversed operations—initiating withdrawals and finalizing deposits.
Key Differentiators from L1 Bridge
- Unified asset handling: ETH treated as ERC-20 token with special address
- Simplified interface: No need to distinguish between ETH and ERC-20 in function parameters
- Automatic L1 address resolution: L2 tokens provide their L1 counterparts automatically
Withdrawal Process
The L2 bridge handles withdrawals by:
- Burning the appropriate amount of L2 tokens
- Determining the corresponding L1 token address
- Sending cross-domain messages for L1 withdrawal finalization
- Emitting appropriate events for tracking and verification
Deposit Finalization
When finalizing deposits from L1, the L2 bridge:
- Validates message authenticity through cross-domain verification
- Performs sanity checks on the L2 token contract
- Mints tokens to the recipient if validation passes
- Initiates refund process if validation fails
Security Considerations
The Optimism bridge implementation incorporates multiple security layers:
- Cross-domain authentication: Verifies all messages originate from legitimate counterparts
- Interface validation: Uses ERC-165 to confirm contract compatibility
- Access control: Restricts minting/burning to bridge contracts only
- Asset tracking: Maintains accurate deposit records to prevent overspending
- Upgrade safety: Uses proxy patterns for secure contract upgrades
Frequently Asked Questions
How long does it take to withdraw assets from Optimism to Ethereum?
Withdrawals typically require a 7-day challenge period before finalization on L1. This security mechanism ensures proper fraud detection and prevention. Third-party bridges often provide faster withdrawals by utilizing liquidity pools.
What's the difference between standard bridges and third-party bridges?
Standard bridges are official, non-custodial solutions with maximum security but longer withdrawal times. Third-party bridges often provide faster withdrawals using liquidity pools but may involve different trust assumptions and fees.
Can any ERC-20 token be bridged to Optimism?
While the standard bridge supports most ERC-20 tokens, token developers must deploy an L2 counterpart that implements the IL2StandardERC20 interface. Some tokens with unusual functionality may require custom bridge implementations.
How are gas fees handled for cross-chain transactions?
L1→L2 transactions include gas parameters that determine execution costs on Optimism. L2→L1 transactions require gas on both layers—for the initial withdrawal initiation on L2 and the finalization transaction on L1 after the challenge period.
What happens if a deposit fails validation on L2?
If deposit validation fails (incorrect L2 token address or interface issues), the bridge automatically initiates a withdrawal process to return the assets to L1. This process still requires the challenge period but prevents permanent asset loss.
Are there any limits on bridge transfer amounts?
The standard bridge itself doesn't impose transfer limits, but individual tokens might have their own limitations. Users should also consider gas costs, which make very small transfers economically impractical.
Conclusion
The Optimism Standard Bridge provides a secure, non-custodial method for transferring assets between Ethereum Mainnet and Optimism. Its sophisticated contract architecture ensures asset security through multiple validation layers while maintaining compatibility with standard token implementations.
While the standard bridge offers maximum security, users often prefer third-party bridges for faster withdrawals, particularly for smaller amounts where the waiting period and gas costs become significant factors. These alternative bridges use liquidity pools to provide instant withdrawals while managing the standard bridge process in the background.
👉 View real-time bridge monitoring tools
Understanding the bridge architecture not only helps users make informed decisions about asset transfers but also provides valuable insights into secure cross-chain development patterns and Layer 2 technology implementation.