This repository contains scripts for performing deposit and withdrawal operations using the Arbitrum SDK. The scripts allow you to deposit ETH from L1 to L2 and withdraw it back to L1, demonstrating the interoperability between Ethereum and Arbitrum networks.
Before running the scripts, ensure you have the necessary dependencies installed and the environment variables configured.
- Node.js
- Environment Variable:
DEVNET_PRIVKEY
: Your private keyL1RPC
: L1 RPC URLL2RPC
: L2 RPC URL
- Initialize Providers and Wallets:
- Set up L1 and L2 providers using RPC URLs.
- Create wallets using the provided private key.
- Configure L2 Network:
- Define and register a custom L2 network configuration.
- Deposit ETH:
- Specify the amount of ETH to deposit.
- Create an EthBridger instance.
- Execute the deposit and wait for confirmation on both L1 and L2.
User-triggered transaction on Parent Chain: Transaction Link
Automatically triggered transaction to deposit on user's wallet on Orbit Chain: Transaction Link
- Initialize Providers and Wallets:
- Set up L1 and L2 providers using RPC URLs.
- Create wallets using the provided private key.
- Configure L2 Network:
- Define and register a custom L2 network configuration.
- Trigger Withdrawal:
- Retrieve the transaction receipt for the deposit.
- Get the L2 to L1 messages from the receipt.
- Check if the message has already been executed.
- Wait for the outbox entry to be created and then execute the withdrawal transaction on L2.
Trigger withdrawal on Orbit Chain: Transaction Link
- Execute Withdrawal on L1:
- Once the outbox entry is created, execute the transaction on the parent chain to complete the withdrawal process.
Execute transaction on Parent Chain: Transaction Link
To run the scripts, follow these steps:
For deposits: npm run start
For Withdraw Step 1: npm run step:1
For Withdraw Step 2: npm run step:2