Optimism is designed so that users can send arbitrary messages between smart contracts on Optimism and Ethereum. This makes it possible to transfer assets, including ERC20 tokens, between the two networks. The exact mechanism by which this communication occurs differs depending on the direction in which messages are being sent.
Optimism uses this functionality in the Standard bridge to allow users to deposit assets (ERC20s and ETH) from Ethereum to Optimism and on also allow withdrawals of the same from Optimism back to Ethereum. See the developer documentation and examples on details on the inner workings of the Standard bridge.
Moving from Ethereum to Optimism
To send messages from Ethereum to Optimism, users simply need to trigger the
CanonicalTransactionChain contract on Ethereum to create a new block on Optimism block. See the above section on block production for additional context. User-created blocks can include transactions that will appear to originate from the address that generated the block.
Moving from Optimism to Ethereum
It's not possible for contracts on Optimism to easily generate transactions on Ethereum in the same way as Ethereum contracts can generate transactions on Optimism. As a result, the process of sending data from Optimism back to Ethereum is somewhat more involved. Instead of automatically generating authenticated transactions, we must instead be able to make provable statements about the state of Optimism to contracts sitting on Ethereum.
Making provable statements about the state of Optimism requires a cryptographic commitment in the form of the root of the Optimism's state trie. Optimism's state is updated after each block, so this commitment will also change after every block. Commitments are regularly published (approximately once or twice per hour) to a smart contract on Ethereum called the StateCommitmentChain.
Users can use these commitments to generate Merkle tree proofs about the state of Optimism. These proofs can be verified by smart contracts on Ethereum. Optimism maintains a convenient cross-chain communication contract, the
L1CrossDomainMessenger , which can verify these proofs on behalf of other contracts.
These proofs can be used to make verifiable statements about the data within the storage of any contract on Optimism at a specific block height. This basic functionality can then be used to enable contracts on Optimism to send messages to contracts on Ethereum. The
L2ToL1MessagePasser contract (predeployed to the Optimism network) can be used by contracts on Optimism to store a message in the Optimism state. Users can then prove to contracts on Ethereum that a given contract on Optimism did, in fact, mean to send some given message by showing that the hash of this message has been stored within the