Skip to content

feat: make destAddress configurable via command line argument in eth-deposit-to-different-address #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/eth-deposit-to-different-address/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,21 @@ Note that you can also set the environment variables in an `.env` file in the ro

## Run

The script accepts two optional command line arguments:
- `destination_address`: The address on the child chain where the ETH will be sent to (required)
- `amount_in_eth`: The amount of ETH to deposit (optional, defaults to 0.0001 ETH)

```bash
# Basic usage with default amount (0.0001 ETH)
yarn run exec <destination_address>

# Specify custom amount (e.g., 0.001 ETH)
yarn run exec <destination_address> 0.001
```
yarn run exec

Example:
```bash
yarn run exec 0x2D98cBc6f944c4bD36EdfE9f98cd7CB57faEC8d6 0.001
```

<p align="center"><img src="../../assets/offchain_labs_logo.png" width="600"></p>
25 changes: 22 additions & 3 deletions packages/eth-deposit-to-different-address/scripts/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,29 @@ const childChainProvider = new providers.JsonRpcProvider(process.env.CHAIN_RPC);
const parentChainWallet = new Wallet(walletPrivateKey, parentChainProvider);

/**
* Set the destination address and amount to be deposited in the child chain (in wei)
* Get destination address from command line arguments
* Usage: node exec.js <destination_address> [amount_in_eth]
*/
const destAddress = '0x2D98cBc6f944c4bD36EdfE9f98cd7CB57faEC8d6';
const depositAmount = utils.parseEther('0.0001');
const destAddress = process.argv[2];
if (!destAddress) {
console.error('Error: Please provide a destination address as the first argument');
console.error('Usage: node exec.js <destination_address> [amount_in_eth]');
process.exit(1);
}

// Validate the address format
if (!utils.isAddress(destAddress)) {
console.error('Error: Invalid destination address format');
process.exit(1);
}

/**
* Set the amount to be deposited in the child chain (in wei)
* Default to 0.0001 ETH if not specified
*/
const depositAmount = process.argv[3]
? utils.parseEther(process.argv[3])
: utils.parseEther('0.0001');

const main = async () => {
await arbLog('Deposit native token (e.g. Ether) via Arbitrum SDK to a different address');
Expand Down