Submitting Transactions from L1
Guide to Submitting Transactions from L1
Withdrawing ETH via L1 Transaction
Initiating an L2 withdrawal from L1 on the OP Stack is a 3 step process:
- Initiate the Withdrawal on L2 (either via an L1 deposit transaction or direct to L2 transaction)
- Relay the Withdrawal to L1
- This can be done after the Withdrawal has occurred on L2 and a proposer has proposed an output on L1.
- This step can take place up to 1 hour after the withdrawal has been initiated on L2
- Finalize the Withdrawal on L1
- This step can be done no sooner than 7 days after the withdrawal has been relayed due to the fault challenge period of 7 days inherent in the OP stack.
Unichain Contract Addresses
Initiating a withdrawal from L1
Via the command line, call the Optimism Portal Proxy on L1 to create an L2 deposit transaction. The L2 transaction will send the ETH to the L2ToL1Messenger
contract to initiate a withdrawal. You can withdraw up to your total balance on L2 (use cast balance $ADDR -r $L2_RPC_URL
to get your ETH balance on L2).
After your deposit has landed on L1, determine your L2 transaction hash:
Relaying the Withdrawal from L2 to L1
This step initiates your withdrawal on L1. This step requires a proposer to have proposed an output which includes your withdrawal. Proposals occur about once every hour.
Finalizing the L1 Withdrawal
After 7 days, run the withdrawer command again to finalize the withdrawal.
Submitting Arbitrary Transactions from L1
You can perform arbitrary contract calls (e.g., swaps) on L2 via deposit transactions. To create a deposit transaction on L2, call the Optimism Portal Proxy Contract:
For example, to perform a swap on a fork of a Uniswap V2 pool on L2 using this method you can:
-
Use the Uniswap V2 SDK to generate the required calldata for the swap (see docs here)
-
Submit the calldata from step 1, to the
$DEX_ADDRESS
of the V2 fork: -
If you use this method to swap back into ETH on the L2, you can withdraw the resulting ETH using the methods outlined above.
Last updated on