stack-orchestrator/app/data/container-build/cerc-optimism-contracts/hardhat-tasks/send-balance.ts
prathamesh0 be08ee81ea Add ability to run Optimism fixturenet with external L1 endpoint (#273)
* Remove unnecessary todos

* Set option to log commands in shell scripts

* Replace fixturenet-eth dependency with wait on endpoint

* Skip lighthouse node dependency check

* Update all services in the stack

* Use debug flag to enable shell commands logging

* Add bash in op-batcher container

* Update mobymask-v2 instructions

* Update fixturenet-optimism instructions

* Add descriptions for services

* Move ts files to container-build

* Take L1 RPC endpoint from the env file

* Add dev mode restriction for editing env file

Former-commit-id: 2515878eeb
2023-04-04 14:53:28 +05:30

23 lines
879 B
TypeScript

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 }, {}) => {
// Open the wallet using sender's private key
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({
to,
value: ethers.utils.parseEther(amount),
})
console.log(`Balance sent to: ${to}, from: ${wallet.address}`)
console.log(`Transaction hash: ${tx.hash}`)
})