Etherscan API – How to Calculate Real Ethers from Etherscan API

balancesetherscanexternal-api

Having this address:
https://etherscan.io/address/0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8

The balance on the web is 21.76252288478066826 Ether

But using the API the balance is:
https://ropsten.etherscan.io/api?apikey=GY9KKYEJF1HDEPIAIRGA66R2RIQWQXV9UZ&module=account&action=balance&address=0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8&tag=latest

5000014636180791194320764

I don't even know what unit is that. Because the documentation don't say anything.

Best Answer

You are looking at two different networks. The first is on Mainnet, the second is on Ropsten (test network).

If you query the account via the Mainnet API, https://api.etherscan.io/api?module=account&action=balance&address=0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8&tag=latest then you get

{"status":"1","message":"OK","result":"21767542884780668260"}

Units are Wei = 10^-18 Ether. So this is 21.767542884780668260 Eth.

Related Topic