1

I am using the "Get a list of 'Normal' Transactions By Address" method from the Etherscan.io API. The problem is that the results from the API are different than from results from the 'Download CSV export' you get on the this page.

https://etherscan.io/address/0xCeB4d0CA821420Cf2553b9e244F6B52364613F94

Link to the API: https://etherscan.io/apis#accounts

For this address:

0xCeB4d0CA821420Cf2553b9e244F6B52364613F94

The API Get request:

https://api.etherscan.io/api?module=account&action=txlist&address=https://etherscan.io/address/0xCeB4d0CA821420Cf2553b9e244F6B52364613F94&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken

The problem is that the 'value' does not match the 'Value_IN(ETH)' when downloading the data as a .csv file.

In the .csv file the results look like:

Txhash: 0x1f55419fa826e9d9b5487ce745f22c0d6066cf8da8e02bb84a105f6fcf34f8e2

Value_IN(ETH) : 0.0500459770509325

The .csv file is correct. That is what happened with that wallet there.

However in the .json object returned from the API call I get these results:

hash : '0x1f55419fa826e9d9b5487ce745f22c0d6066cf8da8e02bb84a105f6fcf34f8e2'

value : '50045977050932511'

I don't understand why these values are different. Is it something in the encoding that I am missing?

1 Answer 1

2

'value' is returned in Wei, the base unit of Ethereum.

There are 10^18 Wei in one Ether. So to convert from wei to ether just divide it by 10^18.

def convert_wei_to_ether(amount_wei):
    amount_ether = float(amount_wei) / math.pow(10, 18) 
    return amount_ether

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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