Avoid using hardhat ethers to send balances from an account

This commit is contained in:
Prathamesh Musale 2023-03-31 13:35:33 +05:30
parent 1fe0138578
commit 66044072c2
2 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,5 @@
#!/bin/bash
set -e
# Append tasks/index.ts file
echo "import './rekey-json'" >> tasks/index.ts

View File

@ -1,13 +1,15 @@
import { task } from 'hardhat/config'
import '@nomiclabs/hardhat-ethers'
import { ethers } from 'ethers'
task('send-balance', 'Sends Ether to a specified Ethereum account')
.addParam('to', 'The Ethereum address to send Ether to')
.addParam('amount', 'The amount of Ether to send, in Ether')
.addParam('privateKey', 'The private key of the sender')
.setAction(async ({ to, amount, privateKey }, { ethers }) => {
.setAction(async ({ to, amount, privateKey }, {}) => {
// Open the wallet using sender's private key
const wallet = new ethers.Wallet(privateKey, ethers.provider)
const provider = new ethers.providers.JsonRpcProvider(`${process.env.L1_RPC}`)
const wallet = new ethers.Wallet(privateKey, provider)
// Send amount to the specified address
const tx = await wallet.sendTransaction({