Skip to content

Commit

Permalink
🥑 task
Browse files Browse the repository at this point in the history
  • Loading branch information
coolcode committed Jan 29, 2024
1 parent 981c0b4 commit c83e840
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
6 changes: 1 addition & 5 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import "@nomicfoundation/hardhat-toolbox"
import "@typechain/hardhat"
import { HardhatUserConfig, task } from "hardhat/config"

import Balance from "./tasks/Balance"

task("balance", "Prints an account's balance")
.addParam("account", "The account's address")
.setAction(Balance)
import "./tasks/Balance"

const config: HardhatUserConfig = {
solidity: {
Expand Down
24 changes: 11 additions & 13 deletions tasks/Balance.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime"
import { task } from "hardhat/config"

export default async (
params: { account: string },
hre: HardhatRuntimeEnvironment
): Promise<void> => {
const ethers = hre.ethers
const accountIndex = params.account
console.info("account index:", accountIndex)
const accounts = await ethers.getSigners()
const address = await accounts[accountIndex].getAddress()
const balance = await ethers.provider.getBalance(address)
task("balance", "Prints an account's balance")
.addParam<string>("account", "The account's address")
.setAction(async (taskArgs, { ethers }) => {
const accountIndex = taskArgs.account
console.info("account index:", accountIndex)
const accounts = await ethers.getSigners()
const address = await accounts[accountIndex].getAddress()
const balance = await ethers.provider.getBalance(address)

console.info(`Balance account ${address}: ${balance}`)
}
console.info(`Balance account ${address}: ${balance}`)
})

0 comments on commit c83e840

Please sign in to comment.