Created
February 3, 2023 21:26
-
-
Save cgcardona/cab91948982be1398a543b67051901f1 to your computer and use it in GitHub Desktop.
erc20.abi.json is found here https://gist.github.com/cgcardona/915852526e48e77364f75921c26245d0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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