Skip to content

Instantly share code, notes, and snippets.

@cgcardona
Created February 3, 2023 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgcardona/cab91948982be1398a543b67051901f1 to your computer and use it in GitHub Desktop.
Save cgcardona/cab91948982be1398a543b67051901f1 to your computer and use it in GitHub Desktop.
task("check-erc20-balance", "Prints out the ERC20 balance of your account").setAction(async function (taskArguments, hre) {
const genericErc20Abi = require("./erc20.abi.json");
const tokenContractAddress = "0x...";
const provider = ethers.getDefaultProvider("https://api.avax.network/ext/bc/C/rpc");
const contract = new ethers.Contract(tokenContractAddress, genericErc20Abi, provider);
const balance = (await contract.balanceOf("0x...")).toString();
console.log(balance)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment