0

Hi' I'm trying to get a balance of erc 20 tokens of given address in my solidity sc, but it always gives me back 0. I tried to play around with it for hours and can't find where the mistake lays. Could someone help, please ?

pragma solidity ^0.4.25;
contract ERC20 { 
    function transfer(address receiver, uint amount) public; 
    function balanceOf(address tokenOwner) public constant returns (uint balance);
}
contract TestErc20{

 function getBalance() public view returns(uint) {
    ERC20 t = ERC20(0xCCF1C01067E4200F0E4ddb1f2f3cCEa85A18aa2C);
   return (t.balanceOf(0xb06029664056f44437F4E82cFB2D6B153513F0B8));
  }
}
  • @Aquila is right, your functions look just fine. Just to be sure, though, you might want to change constant in the ERC20contract to view and remove the brackets around the return value, so you have return t.balanceOf(0xb06029664056f44437F4E82cFB2D6B153513F0B8); – Adibas03 Mar 14 at 8:55
1

Based on provided code I can only say that there is no transfer or token's mint to the address, that is why balance is zero

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.