0

This question already has an answer here:

I want to get token holding of an address with web3.js. If I have an address, 0x00000.....123 is there a way I can get all the tokens that address hold, like etherscan shows the tokens and balances.

I think we can do this other way around, by getting token contract address and ask for balanceOf(address), but that will be a lengthy process, and I need to know tokens contract address beforehand.

Thanks for the help.

marked as duplicate by flygoing, Richard Horrocks, Achala Dissanayake, ivicaa, Community Feb 23 '18 at 9:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Since the balance of a user is only stored in the contract of the token, the only way to get the balances is to query the token address. You'd either have to use an API like Etherscan's to get a list of token addresses, or scan the blockchain yourself to find contracts that look like ERC20 tokens and compile a list to then get the balances of the user on each contract.

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