Skip to content

gelatodigital/arbitrum-orbit-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How TOs 16: Master Arbitrum Orbit Deposit and Withdrawal

Introduction

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.

Repo Structure

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:

  • 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

Setup

Before running the scripts, ensure you have the necessary dependencies installed and the environment variables configured.

Prerequisites

  • Node.js
  • Environment Variable:
    • DEVNET_PRIVKEY: Your private key
    • ParentRPC: Parent RPC URL
    • ChildRPC: Child RPC URL

Deposit

  1. Initialize Providers and Wallets:
    • Set up Parent and Child providers using RPC URLs.
    • Create wallets using the provided private key.
  2. Configure Child Network:
    • Define and register a custom Child network configuration.
  3. 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

Withdrawal

Step 1: Trigger Withdrawal

  1. Initialize Providers and Wallets:
    • Set up Parent and Child providers using RPC URLs.
    • Create wallets using the provided private key.
  2. Configure Child Network:
    • Define and register a custom Child network configuration.
  3. 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

Step 2: Execute Withdrawal

  1. 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

Running the scripts

To run the scripts, follow these steps:

ParentToChain deposits CGT Chain

Deposit Native Token

yarn parentToChild:cgt:deposit:native

Deposit Erc20 Token

parentToChild:cgt:deposit:erc20

Send Tx

yarn parentToChild:cgt:tx

ChildtoParent

Withdraw Native Token

yarn childToParent:withdraw:native

Withdraw Erc20 Token

yarn childToParent:withdraw:erc20

Send Tx

yarn childToParent:sendTx

Parent

Execute Withdraw tx

yarn parent:withdraw:execution

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published