Semi-technical guide for withdrawing ETH from L2

Hey this is ant. As a dev support, I have seen many users struggling to withdraw their funds from Unichain after they have deposited ETH based on a previous leak on RPC info. Even though the fact that the info is not coming from an official announcement thus users should DYOR before aping, still I understand at least some of them will need those money back asap instead of waiting for the mainnet bridge UI to launch.

Therefore I want to share a step-by-step technical guide I wrote to walk you through how you can initiate, prove, and finalize withdrawal from L2 like Unichain. In this guide I break down the steps from the original guide on the Unichain docs, so this is sort of an extended version of that guide but for semi-technical or (relatively) non-technical users.

But prepare yourself, this could still be a tough one...
Just ping me on X in case you run into any issues.

Walkthrough on the technical guide

Step 1. Initiating a withdrawal from L1

  1. Head to the Etherscan of OptimismPortal2 => Write as Proxy => Connect to Web3 (with the wallet you used to send the funds) => find depositTransaction (0xe9e05c42)

For the params pass in the following:*

depositTransaction: (skip this field)
_to: 0x4200000000000000000000000000000000000016
_value: (the amount that you have bridged and want to withdraw from Unichain, use an ETH unit converter e.g. swiss-knife.xyz to help calculate the amount in *wei* by inputting the amount of *Ether* you want to withdraw)
_gasLimit: 300000
_isCreation: false
_data: 0x
*How it will look like on Etherscan after passing in the parameters
*How it will look like on Etherscan after passing in the parameters

Click on Write and submit the transaction

============================================================

Step 2. After your deposit has landed on L1, find your L2 transaction hash

  1. Go to the Unichain chaineye explorer

  2. Search in the explorer by typing the wallet address you use to bridge from Ethereum mainnet to Unichain in the first place i.e. the one you used to submit the tx in Step 1

  3. Locate the transaction hash* that involves transferring your ETH from Ethereum mainnet to Unichain via the Message Passer Proxy contract 0x4200000000000000000000000000000000000016, this is one of the examples.

So from this example we will pass in 0xa6028dc34c9dce65e28e780243d27717f030f5df5f91a95e72b219336f94afe3 as the L2_TX_HASH for Step 3 and 4 later.

*The transaction will be similar to this in your transaction history
*The transaction will be similar to this in your transaction history

============================================================

Step 3. 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.

You should already have -
a. The L2 transaction hash you found from the explorer in Step 2
b. git downloaded in a Mac
c. golang downloaded in a Mac
d. little ETH for gas in your wallet on L1

“Run” in below means typing what’s inside the code block - e.g. cd ~/Desktop in the terminal and then click “Enter”. If it went through you should enter a new line in the terminal!

  1. Open your terminal, run cd ~/Desktop to set the current directory to Desktop

  2. Run git clone https://github.com/base-org/withdrawer.git to download the project in your Desktop or download directly from their repository*

  3. Run cd withdrawer

  4. Run export L2_TX_HASH=PASTE_YOUR_L2_TRANSACTION_HASH_HERE (replace your actual tx hash with PASTE_YOUR_L2_TRANSACTION_HASH_HERE)

  5. Run export PK=PASTE_YOUR_L1_PRIVATE_KEY (replace PASTE_YOUR_L1_PRIVATE_KEY with your actual Private Key and remove the leading 0x - and pls don't expose your PK to anyone please!)

  6. Run go run main.go --withdrawal $L2_TX_HASH --rpc=https://eth.merkle.io --fault-proofs --l2-rpc=https://mainnet-readonly.unichain.org --portal-address=0x0bd48f6B86a26D3a217d0Fa6FfE2B491B956A7a2 --dfg-address=0x2F12d621a16e2d3285929C9996f478508951dFe4 --private-key=$PK --network=op-mainnet

Note: this can be called from any L1 address, it does not have to be the same address that initiated the withdrawal on the L2.

*In case you can't do `git clone` for some reason, you can still go to their github repo directly to download the ZIP and put it in Desktop
*In case you can't do `git clone` for some reason, you can still go to their github repo directly to download the ZIP and put it in Desktop

============================================================

Step 4. Finalizing the L1 Withdrawal

After 7 days, run the withdrawer command again to finalize the withdrawal.

Users are required to wait for a period of seven days when moving assets out of L2 into the Ethereum mainnet. This period of time is called the Challenge Period and serves to help secure the assets stored on L2.

  • Open your terminal, go to the path where you downloaded the withdrawer project on Step 3(usually run cd ~/Desktop if you follow along) and run cd withdrawer

For the following they are basically the same steps as (4) - (6) in Step 3 above

  1. Run export L2_TX_HASH=PASTE_YOUR_L2_TRANSACTION_HASH_HERE (replace your actual tx hash with PASTE_YOUR_L2_TRANSACTION_HASH_HERE)

  2. Run export PK=PASTE_YOUR_L1_PRIVATE_KEY (replace PASTE_YOUR_L1_PRIVATE_KEY with your actual Private Key and remove the leading 0x - and don't expose your PK to anyone please!)

  3. (Same command as (6) in Step 3) Run go run main.go --withdrawal $L2_TX_HASH --rpc=https://eth.merkle.io --fault-proofs --l2-rpc=https://mainnet-readonly.unichain.org --portal-address=0x0bd48f6B86a26D3a217d0Fa6FfE2B491B956A7a2 --dfg-address=0x2F12d621a16e2d3285929C9996f478508951dFe4 --private-key=$PK --network=op-mainnet

Note: this can be called from any L1 address, it does not have to be the same address that initiated the withdrawal on the L2.

You should now have the ETH withdrawn back to Ethereum mainnet after the withdrawal is finalized.

============================================================

Conclusion

In this guide we have learnt how to initiate a withdrawal via Optimism’s message passing contract, and utilize the scripts from Base to help prove and finalize our withdrawal from OP stack based chains.

If you notice you will see that actually you can reference this guide to basically withdraw from any L2s which are built on OP stack by replacing with the right context(e.g. the explorer for finding the L2 tx hash, the L2 RPC etc)!

As Unichain is approaching the mainnet launch I definitely encourage you to keep an eye on their exciting features such as 250ms “Flashblocks” and their Decentralized Validation Network. Dive into their whitepaper as well if you are feeling technical👀

Maybe you will want to deposit even more ETH to Unichain after reading that xD

Last but not least again if you run into any issues during the steps, or if you found anything that you think should be updated in this guide to make it easier for everyone to understand, definitely let me know by pinging me on X.

Feel free to mint this guide or subscribe to my blog for more technical sharing or my thoughts on crypto(if I will even do any lol) :p

🐜

Subscribe to ant
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.