2

I'm currently trying to call Etherscan's API eth_call to check data from a smart contract. To do that, I need to pass the function ABI code and data. However, the data I need is stored in a map and I'm not sure what code that would map to.

The contract in question is here with the variable being

mapping (address => bool) public sendAllowed;

However, by doing

Keccack ("sendAllowed(address)") = 2f0c92d385bd4391c0edec32b0ac39252f8a9ecbcfb630748ddb154a80318288

I got the ABI code of 0x2f0c92d3. Plugging that into the Etherscan API, I didn't get the proper data though:

http://api-rinkeby.etherscan.io/api?module=proxy&action=eth_call&address=0xf455105e41f84e3f980d0908887a311233bb9953&data=0x2f0c92d3dc1f5d644e4016f3da89fe002f63fbeb8e071cf1&apikey=YOURAPIKEY

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

(should return true)

What is the correct ABI code to use for the public getter / how do I properly call the Etherscan API to get the data?

ThePiachu
  • 562
  • 1
  • 6
  • 14

1 Answers1

2

You got the function selector right (0x2f0c92d3), but you failed to correctly ABI encode the address parameter. It should be left-padded with zeros so that it's 32 bytes wide. Try this instead:

0x2f0c92d3000000000000000000000000dc1f5d644e4016f3da89fe002f63fbeb8e071cf1
user19510
  • 27,999
  • 2
  • 30
  • 48
  • http://api-rinkeby.etherscan.io/api?module=proxy&action=eth_call&address=0xf455105e41f84e3f980d0908887a311233bb9953&data=0x2f0c92d3000000000000000000000000dc1f5d644e4016f3da89fe002f63fbeb8e071cf1 still returns result of 0x, while it should return true... – ThePiachu Sep 20 '19 at 15:34
  • 1
    Your URL has address= instead of to=. This URL works as expected: http://api-rinkeby.etherscan.io/api?module=proxy&action=eth_call&to=0xf455105e41f84e3f980d0908887a311233bb9953&data=0x2f0c92d3000000000000000000000000dc1f5d644e4016f3da89fe002f63fbeb8e071cf1 – user19510 Sep 20 '19 at 16:01