I try to simply check a users DAI token balance on Kovan testnet (ContractAddress: 0xC4375B7De8af5a38a93548eb8453a498222C4fF2) with the following code:
pragma solidity ^0.4.16;
contract ERC20 {
function balanceOf(address who) constant returns (uint256);
}
contract myTest {
ERC20 myToken;
function setToken(address tokenAddress) {
myToken = ERC20(tokenAddress);
}
function getTokenBalanceOf(address h0dler) constant returns (uint balance) {
return myToken.balanceOf(h0dler);
}
}
When exucting the getTokenBalanceOf function Remix throughs an error:
"call to myTest.getTokenBalanceOf errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information. "
balanceOf
is not implemented! Also note that in functiongetTokenBalanceOf
, you're not doing anything with variablebalance
, so you may as well remove it.function balanceOf(address who) constant returns (uint256);
is not implemented. But I apologize, it actually will compile and can run correctly if that function is implemented by the contract deployed at0xC4375B7De8af5a38a93548eb8453a498222C4fF2
. I suggest that you verify that this function is actually implemented there, and that it doesn't revert for some other reason.