I am trying to get a descending list of biggest token holders like is displayed on etherscan. I could not locate an api to do this. I looked at EtherScan and EthPlorers api but did not see anything pertaining to this.

Does anyone know how i can do this in java?

  • I am working on a token explorer, currently I extract ERC20 tokens only. My project is extracting data at more deeper level than Etherscan, for example I am linking the event to internal transaction, this way you can separate transfer() and transferFrom() transactions while Etherscan can't do this. If you want , we can work together, its an open source project – Nulik Sep 3 '18 at 16:47
  • and btw, golang is cooler than Java for server programming, you should take a look at it, in the future it has all the chances to become the number #2 programming language after C/C++ – Nulik Sep 3 '18 at 16:50

To get a descending list of all token holders you need to customize your own api by saving all token holders in an array and their respective tokens. Other than that you can use third party solution :-


Though you can find tokens at particular address by creating an api :-

const contractInstance = web3.eth.contract(abiData).at(contract_addr);
contractInstance.balanceOf.call(data.public_key, (err, result) => {

if (result) {            
next(null, result);        

else if (err && err.message)

next(err.message, null);      
else {          
 next('Unable to sendRawTransaction', null);    
  • This is not java, and the third party example code does not return just top holders – Adrian Le Roy Devezin Sep 3 '18 at 13:48
  • 2
    Third party such as etherscan let you see holders of token. – Puneet Kumar Sep 6 '18 at 6:05

I do not have exact answer how to do it in Java, but I have close answer how to do it Python. You should be able to replicate this solution using web3j from Python web3.py logic.

ERC-20 tokens do not maintain an iterable list of current token holders, the used mapping type allows you only to check for a known address - balance. To get a list of all token holders, you need to process this offline and build it yourself from blockchain data.

I have created a standalone tool which collects ERC-20 token holders and transactions to SQLite database

  • Take a token contract address

  • Iterate over all Transfer events for token using eth_getLogs JSON-RPC API

  • Build a local database of these events

  • Allow you to use SQL to query any account balance on any point of time (block num)

The tool maintains a local SQLite database. The subsequent command runs scan the new blocks, since last run, and write the new transactions to the database. Exporting this from SQL based on a timestamp should be quite easy.

You can find the command line application execution example how to build the token holder database here

The core Python logic is here.

There are some quirks here and there: for example detecting mint / creation event for some tokens is not straightforward. Thus, you will may negative balance on the account receiving initial total supply if you rely on Transfer event only.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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