Add Optimism Fixturenet stack #266

Merged
prathamesh0 merged 26 commits from pm-fixturenet-optimism into main 2023-04-03 07:03:47 +00:00
Showing only changes of commit abb868eaf0 - Show all commits

View File

@ -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}`)
})