3

Let's say we have information about WePower contract.

I would like get some information about this contract via API. For eg. this,

https://api.etherscan.io/api?module=contract&action=getabi&address=0x4CF488387F035FF08c371515562CBa712f9015d4&apikey=YourApiKeyToken

But there are no values of parameters -- only it's description(contract ABI ). Is there are any methods to get it?

  • your question is bit unclear to me, what do exactly want to know? Aren't you getting a response from etherscan or what? – Achala Dissanayake Feb 5 '18 at 17:57
  • I want to get value of 'paused' parameter via api. thank you for help – imnotyourguru Feb 5 '18 at 18:00
1

You are here, from the API call with the query param action=getabi, requesting the ABI of the contract. So it supposed to return the ABI but nothing else, as you have correctly gotten.

Since you need to read a value of a variable in the contract using query param action=eth_call might do this. Refer this discussion here as well.

UPDATE:

I think, I got it working. I haven't dealt much with etherscan API. But I think this is what you are looking for.

As per the discussion above mentioned, you first need to get the Keccak-256 Hash value of paused() and get the sub-string of 8 characters and join 0x to the front => 0x5c975abb. Then query param data should set to that. i.e. data=0x5c975abb.

Then the API url should look like;

https://api.etherscan.io/api?module=proxy&action=eth_call&to=0x4CF488387F035FF08c371515562CBa712f9015d4&data=0x5c975abb&apikey=my-api-key=YourAPIKey

The response I got looked;

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

The result should be the value of paused which is 1 means true.

  • can't read using query param action=eth_call. should install ethereum client? – imnotyourguru Feb 5 '18 at 19:07
  • 1
    nope, it seems just an api call would do. I think I got it working let me update the answer – Achala Dissanayake Feb 5 '18 at 19:09
3

As @AchalaDissanayake have correctly mentioned, You are requesting the ABI from the Etherscan API. That's why you get the description.

You should alter the API url to get internal data from the contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.