balance.ts 414 B

1234567891011121314
  1. import { task } from "hardhat/config"
  2. /**
  3. Example:
  4. npx hardhat balance --account 0x7B36b05B0E2Ee8A66816473AD848e0da073F7019 --network sepolia
  5. */
  6. task("balance", "Prints an account's balance")
  7. .addParam("account", "The account's address")
  8. .setAction(async (taskArgs, { ethers }) => {
  9. const balance = await ethers.provider.getBalance(taskArgs.account)
  10. console.log(ethers.formatEther(balance), "ETH")
  11. })