Such as ERC20token smartcontract, just is the token balance of accounts, i want to make a smart contract to use token contract address and account address to find out the token balance of different accounts or different token


Get this: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol


import "./IERC20.sol";

contract Checker {

  function checkBal(address token, address holder) public view returns(uint) {
    IERC20 token = IERC20(token);
    return token.balanceOf(holder);

That will let you check the balance of any address in any ERC20 token contract you want to inspect.

Hope it helps.

  • thanks,it worked ,it's helpful for me – 123 Dec 30 '19 at 2:35
  • Awesome. The customary forms of thanks are upvotes and accept so that others might find the answer ;-) – Rob Hitchens Dec 30 '19 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.