send-eth.ts 654 B

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