From abb868eaf072729a3d2d9cc0beef157e6e7415ac Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Thu, 30 Mar 2023 19:07:01 +0530 Subject: [PATCH] Avoid reading addresses from a file when sending balances --- .../optimism-contracts/send-balance.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/app/data/config/fixturenet-optimism/optimism-contracts/send-balance.ts b/app/data/config/fixturenet-optimism/optimism-contracts/send-balance.ts index f5c3c688..43976b94 100644 --- a/app/data/config/fixturenet-optimism/optimism-contracts/send-balance.ts +++ b/app/data/config/fixturenet-optimism/optimism-contracts/send-balance.ts @@ -1,5 +1,3 @@ -import fs from 'fs' - import { task } from 'hardhat/config' import '@nomiclabs/hardhat-ethers' @@ -8,24 +6,15 @@ task('send-balance', 'Sends Ether to a specified Ethereum account') .addParam('amount', 'The amount of Ether to send, in Ether') .addParam('privateKey', 'The private key of the sender') .setAction(async ({ to, amount, privateKey }, { ethers }) => { - const fileContent = fs.readFileSync('/l2-accounts/keys.json', 'utf-8') - const keySet = JSON.parse(fileContent) - - // Get the dest account address from the json file if key present - let address: string = to - if (to in keySet) { - address = keySet[to].address - } - // Open the wallet using sender's private key const wallet = new ethers.Wallet(privateKey, ethers.provider) // Send amount to the specified address const tx = await wallet.sendTransaction({ - to: address, + to, value: ethers.utils.parseEther(amount), }) - console.log(`Balance sent to: ${address}, from: ${wallet.address}`) + console.log(`Balance sent to: ${to}, from: ${wallet.address}`) console.log(`Transaction hash: ${tx.hash}`) })