[ethers.js] ERC20 balance 체크

hardhat task로 만든 ERC20 잔액 확인 태스크

task("balanceERC20", "Check the balance of ERC20 token")
  .addPositionalParam("tokenAddress", "ERC20 Token contract address")
  .addPositionalParam("address", "Address to be checked")
  .setAction(async (taskArgs) => {
    const ERC20 = await ethers.getContractFactory("@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20");
    const erc20 = await ERC20.attach(taskArgs.tokenAddress);
    console.log(ethers.formatEther(await erc20.balanceOf(taskArgs.address)), await erc20.symbol());
  });