Search code examples
tokenweb3jsetherscan

Get number of token holders and number of transactions from Etherscan Token Tracker


I've already got the number of total supply tokens using web3.js But now I faced the problem that I don't have any idea how to get the number of token holders (I don't need the list of holders) and the number of transactions. I think it is very similar. Is it possible to do it using web3.js? I take my test token in rinkeby network for tests: https://rinkeby.etherscan.io/token/0x3ead2f2dacdcba32f9834a71464cae15a88755e8 or Binance token in mainnet https://etherscan.io/token/0xB8c77482e45F1F44dE1745F52C74426C631bDD52


Solution

  • This is not directly supported by the ERC-20 token. So if you want to do this you will have to add extra functionality yourself and keep track who has tokens and who not every time a transfer happens. Then you can create a function to get this number. Since it is not supported by the ERC-20 you will not find it on etherscan, you will have to get it yourself. Adding extra functionality will not stop the token from being an ERC-20.

    The other way would be to iterate all of the addresses, which is a really bad idea.

    Or if you have a server running you can listen for all the events on the contract and keep track of the holders in your own database.