OP Stack
Protocol
Smart Contract Overview

Smart Contract Overview

This guide explains how smart contracts work at a high level.

L1 contracts

L2OutputOracle

The L2OutputOracle contract (opens in a new tab) contains the state root of the Optimism blockchain (OP Mainnet, OP Sepolia, etc.). Once fault proofs are activated, it will be the one that receives the result of the fault proof process.

This is the contract that replaces the old State Commitment Chain.

OptimismPortal

The OptimismPortal contract (opens in a new tab) provides the low-level API for communications between layers. Unless you are trying to send L2 transactions via L1 to bypass the sequencer, we strongly recommend sending messages between L1 and L2 via the L1CrossDomainMessenger and L2CrossDomainMessenger.

L1CrossDomainMessenger

The L1CrossDomainMessenger contract (opens in a new tab) is used for sending messages between the underlying L1 (Ethereum, Sepolia, etc.) and L2 (OP Mainnet, OP Sepolia, etc.).

L1StandardBridge

The L1StandardBridge contract (opens in a new tab) uses L1CrossDomainMessenger to transfer ETH and ERC-20 tokens between the underlying L1 (Ethereum, Sepolia, etc.) and L2 (OP Mainnet, OP Sepolia, etc.).

L2 contracts (predeploys)

L1Block

The L1Block contract (opens in a new tab) sits at address 0x4200000000000000000000000000000000000015. You can use the getter functions (opens in a new tab) to get these parameters:

  • number: The latest L1 block number known to L2 (the L1BlockNumber contract is still supported to avoid breaking existing applications)
  • timestamp: The timestamp of the latest L1 block
  • basefee: The base fee of the latest L1 block
  • hash: The hash of the latest L1 block
  • sequenceNumber: The number of the L2 block within the epoch (the epoch changes when there is a new L1 block)

Currently the L1 information is delayed by two block confirmations (~24 seconds) to minimize the impact of reorgs.

SequencerFeeVault

The SequencerFeeVault contract (opens in a new tab) handles funding the sequencer on L1 using the ETH base fee on L2.

The fees are calculated using EIP 1559 (opens in a new tab), the same mechanism that Ethereum uses (but with different parameter values).

L2ToL1MessagePasser

The L2ToL1MessagePasser contract (opens in a new tab) is used internally by L2CrossDomainMessenger to initiate withdrawals.

Note that there are two contracts under this name:

L2CrossDomainMessenger

The L2CrossDomainMessenger contract (opens in a new tab) is used to send messages from L2 (OP Mainnet, OP Sepolia, etc.) to the underlying L1 (Ethereum, Sepolia, etc.).

L2StandardBridge

The L2StandardBridge contract (opens in a new tab) is a wrapper around the L2CrossDomainMessenger that can handle token transfers.

WETH9

The WETH9 contract (opens in a new tab) is an ERC-20 token that wraps around ETH to provide extra functionality, such as approvals.

Legacy Contracts

Those are contracts that have been superseded, but are kept in case any deployed contract depends on them.