Reputation: 1175
If I retrieve all erc-20 token transfer events for an address on etherscan and build up the account's portfolio transaction by transaction, I sometimes get a different final portfolio than what is showing in etherscan. Take this random address as an example: https://etherscan.io/address/0xcb0fee000ede5fa999c242f8a553c3bc72e10882#tokentxns
If I retrieve the 49 token transfer events from the etherscan api that this address has been evolved in and build up the portfolio, I get this:
{
"eth 0x0000000000000000000000000000000000000000": 731679809973000,
"SAITAMA 0x8b3192f5eebd8579568a2ed41e6feb402f93f73f": 227746555193135254931,
"SHIBAKEN 0xa4cf2afd3b165975afffbf7e487cdd40c894ab6b": 639343510450,
"RELOADED 0xf68df6df642e8387afc9d03214b78f3087ef8a99": 96143248566060861,
"BABYSAITAMA 0xf79f9020560963422ecc9c0c04d3a21190bbf045": 337410523069872339309,
"ABSHIBA.com 0x5ccce837b41dbd2ad74882889749517935741390": 352134000000000,
"uETH.io 0x8f5a1cb27cfed6a640de424e9c0abbceaad0b620": 85410090000000000000000
}
If I check here manually: https://etherscan.io/tokenholdings?a=0xcb0fee000ede5fa999c242f8a553c3bc72e10882 I instead get this (every balance * 1e18 to get the same units as in the api):
{
"eth 0x0000000000000000000000000000000000000000": 731679809973000,
"SAITAMA 0x8b3192f5eebd8579568a2ed41e6feb402f93f73f": 1070751279259610000000000,
"ABSHIBA.com 0x5ccce837b41dbd2ad74882889749517935741390": 8239291000000000000000000,
"uETH.io 0x8f5a1cb27cfed6a640de424e9c0abbceaad0b620": 85410090000000000000000
}
So as you can see, some of them are correct and some are not. If we take "ABSHIBA.com" as an example, etherscan shows that this address holds 8239291000000000000000000 of it (here: https://etherscan.io/tokenholdings?a=0xcb0fee000ede5fa999c242f8a553c3bc72e10882). However if I build up the portfolio myself, I get that this address only holds 352134000000000 of it. If I check the transfers manually, I see that there is only one "token transfer event" for this address where "ABSHIBA.com" is involved, and is it that someone sent this address 352134000000000 of it. So how is etherscan showing the balance as 8239291000000000000000000? (85410.09 if you change units). Am I missing something? Or is etherscan showing the wrong balance?
Upvotes: 3
Views: 563
Reputation: 885
Here is my take. EtherScan, unfortunately, is not open-source and does not provide an sdk. Alternative solution is to use an open-source indexer such as Blockscout that has an open-source sdk such as @evmexplorer/blockscout.
export type { AddressTokens } from "@evmexplorer/blockscout";
export { fetchTokensAddress} from "@evmexplorer/blockscout";
const data: AddressTokens = await fetchTokensAddress(
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
);
Which contains data in the following format:
[
{
token: {
address: '0x28561B8A2360F463011c16b6Cc0B0cbEF8dbBcad',
circulating_market_cap: '75858317.61202328',
decimals: '9',
exchange_rate: '0.00017784',
holders: '14334',
icon_url: 'https://assets.coingecko.com/coins/images/50348/small/1000000612.jpg?1727248974',
name: 'MOO DENG',
symbol: 'MOODENG',
total_supply: '420690000000000000000',
type: 'ERC-20',
volume_24h: '10219755.637613483'
},
token_id: null,
token_instance: null,
value: '30000105889157756560'
},
...
]
Upvotes: 1