11

While developing a Smart Contract with Solidity on Remix , after creating the contract I'm trying to query a public mapping:

mapping (address => uint256) public balanceOf;

but when I call balanceOf for address 0x9b9731b07b9b5f982289bab87097eade6a4bc25d it throws the following error:

Error encoding arguments: SyntaxError: Unexpected token x in JSON at position 2

Any idea how can I properly call balanceOf?

Achala Dissanayake
  • 5,819
  • 15
  • 28
  • 38

3 Answers3

16

The address needs be surrounded with quotes. "0xca35b7d915458ef540ade6068dfe2f44e8fa733c" should work.

afu802
  • 376
  • 4
  • 8
2

The address has to be provided with quotes. Just like huafu said. Must be double qutoes "". It is not going to work with single qutoes. In Javascript it doesn't matter and I was trying to figure out what I was doing wrong.

This works: "0xca35b7d915458ef540ade6068dfe2f44e8fa733c"

This doesn't work. '0xca35b7d915458ef540ade6068dfe2f44e8fa733c'

Rob Magier
  • 483
  • 2
  • 10
1
contract MyToken
    mapping (address => uint256) public balances;

    function balanceOf(address _owner) constant returns (uint256 balance) {
        return balances[_owner];
    }

    ...
}

Reference - The DAO, version 1.0 with the $50 million bug.

BokkyPooBah
  • 40,274
  • 14
  • 123
  • 193