I am trying to get all Ethereum addresses with more than 0 USDT on them. How do I do this?
Then, how do I do this with any ERC20 contract?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
It is impossible to get all Ethereum addresses with more than 0USDT using smart contract because there are no such interfaces. It is same for all the ERC20 smart contract as like EIP have no interfaces. https://eips.ethereum.org/EIPS/eip-20
There are two ways to get the holders of the USDT.
-First, you can use APIs to get the holders' addresses. https://docs.etherscan.io/api-endpoints/tokens#get-token-holder-list-by-contract-address. (Preferred and free)
-Second, you can calculate all of them by your self.(Not preferred) You can get the USDT contract deployed (same for other ERC20 smart contracts) block and start to analyze the block from that point. On each transaction which is confirmed correctly on block, you can get the log and if you detect, "Transfer" log, it means some amount of the token goes from A to B. So you can make database and add amount of token to B. Ofc, you should subtract to A.