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.
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
Click on Write
and submit the transaction
============================================================
Go to the Unichain chaineye explorer
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
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.
============================================================
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!
Open your terminal, run cd ~/Desktop
to set the current directory to Desktop
Run git clone https://github.com/base-org/withdrawer.git
to download the project in your Desktop or download directly from their repository*
Run cd withdrawer
Run export L2_TX_HASH=PASTE_YOUR_L2_TRANSACTION_HASH_HERE
(replace your actual tx hash with PASTE_YOUR_L2_TRANSACTION_HASH_HERE
)
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!)
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.
============================================================
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.
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
Run export L2_TX_HASH=PASTE_YOUR_L2_TRANSACTION_HASH_HERE
(replace your actual tx hash with PASTE_YOUR_L2_TRANSACTION_HASH_HERE
)
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!)
(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.
============================================================
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
🐜