This repository contains deposit and withdrawal operations scripts using the Arbitrum SDK v4. The scripts allow you to deposit native tokens and erc20 from Parent to Child and withdraw them back to Parent, demonstrating the interoperability between EVM and Orbit chains.
We have a set of scritps organized in four main folders:
-
ParentToChild: with scripts to deposit native tokens, erc20s and to send transactions to child chain. This category also has two sub-categories:
- Orbit chain with ETH as native token
- Orbit chain with CGT (Custom Gas Token) as native token
-
ChildToParent: with scripts to withdraw native tokens, erc20s and to send transactions to parent chain.
-
Child. Script to manual redeem a retryable ticket (deposit) if it didn't execute automatically.
-
Parent: Script to execute withdrawals and txs childToParent when the challenge period is over.
In order to use the Arbitrum/sdk we need to pass an object with the Orbit chain config. Please check the Helpers Folder with examples of config with eth: reya cronos example or [cgt](./src/helpers/custom-network-novastro.ts: novastro example) as native token
Before running the scripts, ensure you have the necessary dependencies installed and the environment variables configured.
- Node.js
- Environment Variable:
DEVNET_PRIVKEY
: Your private keyParentRPC
: Parent RPC URLChildRPC
: Child RPC URL
- Initialize Providers and Wallets:
- Set up Parent and Child providers using RPC URLs.
- Create wallets using the provided private key.
- Configure Child Network:
- Define and register a custom Child network configuration.
- Deposit ETH:
- Specify the amount of ETH to deposit.
- Create an EthBridger instance.
- Execute the deposit and wait for confirmation on both Parent and Child.
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 Parent and Child providers using RPC URLs.
- Create wallets using the provided private key.
- Configure Child Network:
- Define and register a custom Child network configuration.
- Trigger Withdrawal:
- Retrieve the transaction receipt for the deposit.
- Get the Child to Parent 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 Child.
Trigger withdrawal on Orbit Chain: Transaction Link
- Execute Withdrawal on Parent:
- 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:
Deposit Native Token
yarn parentToChild:cgt:deposit:native
Deposit Erc20 Token
parentToChild:cgt:deposit:erc20
Send Tx
yarn parentToChild:cgt:tx
Withdraw Native Token
yarn childToParent:withdraw:native
Withdraw Erc20 Token
yarn childToParent:withdraw:erc20
Send Tx
yarn childToParent:sendTx
Execute Withdraw tx
yarn parent:withdraw:execution