send-eth.ts 528 B

12345678910111213141516
  1. import { task } from "hardhat/config"
  2. task("send-eth", "Send ETH to an address")
  3. .addParam<string>("recipient", "Recipient of ETH")
  4. .addParam<string>("value", "Amount of ETH to send")
  5. .setAction(async (taskArgs, { ethers }) => {
  6. const account = (await ethers.getSigners())[0]
  7. const sendTrx = await account.sendTransaction({
  8. to: taskArgs.recipient,
  9. value: ethers.parseEther(taskArgs.value),
  10. })
  11. console.log(`Transaction Hash: ${sendTrx.hash}`)
  12. await sendTrx.wait(2)
  13. console.log("Transaction confirmed")
  14. })