Bridging ETH
Bridge ETH from Ethereum to GIWA, and from GIWA to Ethereum.
Requirements
Make sure the following are installed.
Set up development environment
In this tutorial, we’ll use viem. Viem is a Node.js library, so we’ll start by creating a Node.js project.
Prepare a wallet
You’ll need a wallet to bridge ETH.
Get Sepolia ETH
For a deposit (Ethereum -> GIWA), you need ETH on the Ethereum Sepolia network. Use this faucet to get Sepolia ETH.
Configure the Chain Client
Set up chain client for ETH bridging.
Deposit ETH (Ethereum -> GIWA)
Let’s bridge ETH from Ethereum to GIWA.
When you run the code below, your ETH on Ethereum is actually sent to the OptimismPortal contract. The same amount is then minted and credited to your GIWA wallet. This process is known as Lock-and-Mint.
Withdraw ETH (GIWA -> Ethereum)
Have you successfully sent ETH from Ethereum to GIWA? Now let’s bridge it back in the opposite direction — from GIWA to Ethereum.
When you run the code below, your ETH on GIWA is actually sent to the L2ToL1MessagePasser contract. The same amount is then released to your Ethereum wallet. In this case, the ETH that was originally locked in the OptimismPortal contract during the deposit gets unlocked. This process is called Burn-and-Unlock.
Why does a withdrawal take so long?
Prove wait time: To prove a withdrawal transaction from L2 on L1, a dispute game must be initiated on L1 that includes the L2 transaction. On GIWA, dispute games are started at most every 2 hours, so it may take up to 2 hours before the withdrawal can be proven.
Challenge Period: GIWA is an L2 built on the OP Stack and adopts the Optimistic Rollup model. To confirm that the L2 state at a given point is correct, a dispute game must be completed. This challenge period takes about 7 days, so a withdrawal cannot be finalized until approximately 7 days have passed.
Learn more
Check out the viem docs for additional resources.
Last updated