1

I'm trying to query a contract function that takes uint256 as input via Etherscan's API but I keep getting error messages. The format I've realized should be as follows based on this answer:

http://etherscan.io/api?module=proxy&action=eth_call&to=[address]&data=0x[function hash]000000000000000000000000[read input]

I got the function hash from remix but I can't find what should be added after it for a uint256 input.

Curtis S.
  • 13
  • 2

1 Answers1

2

The argument must be in hex, padded to 32 bytes.

For example, for tokenId 200 (0xc8 in hex):

https://api.etherscan.io/api?module=proxy&action=eth_call&to=0x60F80121C31A0d46B5279700f9DF786054aa5eE5&data=0x6352211e00000000000000000000000000000000000000000000000000000000000000c8

Correctly returns:

{"jsonrpc":"2.0","id":1,"result":"0x000000000000000000000000b687a0a94d2daeec6814b659c4fb3db3768ff2a1"}

Which is the address of the owner of that token, again padded to 32 bytes.

Richard Horrocks
  • 37,835
  • 13
  • 87
  • 144