Avoid using hardhat ethers to send balances from an account
This commit is contained in:
		
							parent
							
								
									1fe0138578
								
							
						
					
					
						commit
						66044072c2
					
				| @ -1,4 +1,5 @@ | ||||
| #!/bin/bash | ||||
| set -e | ||||
| 
 | ||||
| # Append tasks/index.ts file | ||||
| echo "import './rekey-json'" >> tasks/index.ts | ||||
|  | ||||
| @ -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({ | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user