I want to get a list of token holders. Etherscan currently does this, however it is days behind and is very slow to update / reindex the token holder list. How can I get a updated list of token holders that is fairly recent? What tools or APIs can I use to accomplish this? Thanks.

  • If websites like etherscan or ethplorer.io are not as up to date as you would like try using Parity. What r u using for ethereum? – Koka May 13 '18 at 18:37
  • If you are comfortable with communicating directly with the blockchain you can just query the token contract - it has all the info you need – Lauri Peltonen May 13 '18 at 18:45
  • @LauriPeltonen that would be possible with web3 and metamask, right? – user39586 May 13 '18 at 18:46
  • yes. That's probably the easiest way. – Lauri Peltonen May 13 '18 at 18:51
  • @LauriPeltonen would you be interested in writing a quick script for a 0.2 ETH reward? – user39586 May 13 '18 at 19:02

Unless your ERC20 token contract has built into it the ability to iterate over the token holders (which is not a good idea nor gas efficient), there is no way to make a list from data available from the contract. This leaves a third party solution (EtherScan -- bad because centralized) or a solution that asks the node for the data.

There are two solutions here: (1) listen for mint events, or (2) find all the transactions to the contract and build the list from these transactions.

In the first case, if you listen for the mint events, you may find this doesn't work depending on the contract. The ERC20 standard says a contract SHOULD emit events when tokens are created or destroyed, but it doesn't say the contract MUST do so. If your contract does generate events, then this is probably the easiest way to get the list you're looking for. But note, that you have to watch for later transfers if you want to keep an up to date list.

The second option, if you don't want to use a third-party, is to find all the transactions on the contract. This is difficult because finding transactions is not easy because of things like multi-sig wallets.

At QuickBlocks we take a different approach. What we do is scan the blocks looking for transactions (both internal and external) looking for any address that ever interacted with the token contract. At this first pass, we don't care in what way the address interacted, just that it was involved in some transaction with the token.

Given this list, we then spin through that list and request the balance for that address and report the non-zero token balances. It's different, but pretty effective.

Here's a video explaining what I'm talking about: https://m.youtube.com/watch?v=c_KNulh3PF4


As you can't iterate over the balances mapping in ERC20 token contract you have to go through emitted events and filter those. This is not a nice or trivial task and includes some heavy processing - this is probably why etherscan updates so rarely.

Here are some answers which accomplish similar things: