0

following to the approach explained here to use etherscan api from Python to get transactions info such as input

How to retrieve transactions' info such as gaslimit and gasprice from Etherscan?

How can I decode transaction input to know what method was called and what arguments were passed in (and arguments types)?

In addition, is there a way to retrieve all verified contracts from etherscan? especially to retrieve creation code for each contract and the all contract's transactions?

1

An example of a response from etherscan API for transactions this:

{"jsonrpc":"2.0","id":1,"result":{
"blockHash":"0xf64a12502afc36db3d29931a2148e5d6ddaa883a2a3c968ca2fb293fa9258c68",
"blockNumber":"0x70839",
"from":"0xc80fb22930b303b55df9b89901889126400add38",
"gas":"0x30d40",
"gasPrice":"0xba43b7400",
"hash":"0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1",
"input":"0xfc36e15b0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a4861636b65726e65777300000000000000000000000000000000000000000000",
"nonce":"0xa7",
"to":"0x03fca6077d38dd99d0ce14ba32078bd2cda72d74",
"transactionIndex":"0x0",
"value":"0x0",
"v":"0x1c",
"r":"0xe7ccdba116aa95ae8d9bdd02f619a0cdfc1f60c5740b3899865822a80cd70218",
"s":"0xf200df1921ea988d16280a0873b69cb782a54e8a596d15e700710c820c8d2a9e"}}

The input is what you are interested in.

The first 4 bytes are the method (function) that is being called. The remaining are the parameters in words of 32bytes.

If you want to know the function name and types of the parameters you need to know the contract (ABI). Having the ABI you just need to make a quick look for the method.

You can retrieve the contracts you need to know the addresses, there is no way to download all at once. see here

Hope this helps

  • Thanks Jaime! i know how to get the contract API, but i need an automatic way (instead of manually looking at it) that return a function name and its required parameter by passing transaction input & contract api if required. for retrieving contracts, i think you are right since i tried and searched a lot, but did not find a way! – MWH Mar 11 at 21:53

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.