Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more usefull tasks #63

Merged
merged 8 commits into from
Oct 5, 2024
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import "./tasks/get-statuses-after-execution";
import "./tasks/depositSC";
import "./tasks/set-batch-settle-limit-on-safe"
import "./tasks/deploy";
import "./tasks/token-balance-query"

import { resolve } from "path";

Expand Down
20 changes: 20 additions & 0 deletions tasks/token-balance-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import "@nomicfoundation/hardhat-toolbox";

task("token-balance-query", "Query the balance of the provided address for the defined tokens")
.addParam("address", "Address for the balance query")
.setAction(async (taskArgs, hre) => {
const fs = require("fs");
const filename = "setup.config.json";
let config = JSON.parse(fs.readFileSync(filename, "utf8"));
const address = taskArgs.address;

console.log("Querying ERC20 balance of the address", address);
for (let token of config["tokens"]) {
const tokenContract = (await hre.ethers.getContractFactory("GenericERC20")).attach(token);
await tokenContract.balanceOf(address)
.then((balance: any) => {
console.log(`Balance of token ${token.toString()}: ${balance.toString()}`);
})

}
});
Loading