Q:

Problem loading token balances [solved]

I have a contract with the decimals hardcoded to 8
    // Hardcoded to be a constant
    uint8 public constant decimals = 8;

I think this is the reason Im having problems with wallets and explorer to show token balances..
Metamask says: "We had trouble loading your token balances. You can view them here"
How can I show correctly my tokens?
Also can be possible to use 18 decimals, but then I would need to modify this:
    // constant to simplify conversion of token amounts into integer form
    uint256 public tokenUnit = uint256(10)**decimals;

Any tip about what can be the best solution and how I can do it?
Thanks!

A:

Your contract is not ERC20-compliant.
More specifically, it does not implement function balanceOf as dictated by the standard:

Returns the account balance of another account with address _owner.
function balanceOf(address _owner) public view returns (uint256 balance)

I noticed that you have implemented something similar in your contract:
function tokenBalanceOf(address _owner) public view returns (uint256 balance) {
    return balances[_owner];
}

So it looks like you just need to rename it from tokenBalanceOf to balanceOf.
I would also get rid of the balance variable name in the function declaration, because it adds confusion, and because it is possibly even harmful. I'm not really sure how the Solidity compiler handles the ambiguity in this function, i.e., whether it returns balance (which is obviously always set to 0) or balances[_owner].

