Add Optimism Fixturenet stack #266
@ -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}`)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user