Best Way to Explain How to Send data between L1 and L2 Optimism

Optimism can be made to interact with apps on Ethereum via a process called “bridging”. In a nutshell, contracts on Optimism can trigger contract functions on Ethereum, and vice versa. With just a little bit of elbow grease, you too can create contracts that bridge the gap between Layer 1 and Layer 2 world wild!

Optimism

Communication basics between layers

At a high level, this process is pretty similar to the same process for two contracts on Ethereum (with a few caveats). Communication between L1 and L2 is enabled by two special smart contracts called the “messengers”. Each layer has its own messenger contract which serves to abstract away some lower-level communication details, a lot like how HTTP libraries abstract away physical network connections.

Communication speed

Unlike calls between contracts on the same blockchain, calls between Ethereum and Optimism are not instantaneous. The exact speed of a cross-chain transaction depends on the direction in which the transaction is sent world wild.

Ethereum (L1) to Optimism (L2) transactions

Transactions sent from L1 to L2 take up to approximately 15 minutes on mainnet and 5 minutes on the Optimism Goerli testnet to reach the target L2 contract. This is because L2 nodes will wait for a certain number of block confirmations on Ethereum before executing an L1 to L2 transaction.

Optimism (L2) to Ethereum (L1) transactions

L2 to L1 transactions have to wait two periods:

The time until the state root is written to L1. You can estimate this time by looking at how often transactions happen to the State Commitment Chain (on both mainnet (opens new window) and goerli (opens new window)).

As of the Bedrock update, it is necessary to provide a Merkle proof of the message on L1 after the state root is written. The fault challenge period starts after that proof transaction becomes part of the L1 chain.

The fault challenge period, which is a few seconds on goerli and seven days on mainnet. This waiting period is a core part of the security mechanism designed to keep funds on Optimism secure and cannot be circumvented. After this waiting period, any user can “finalize” the transaction by triggering a second transaction on Ethereum that sends the message to the target L1 contract.

Add a Comment

Your email address will not be published. Required fields are marked *