What's the best way to get the list of token(ERC20) holders with their balance at a specific time? Thank you.

  • 2
    Getting the list is hard. (Easiest way is probably to process all the logs for the contract looking for Transfer events.) Getting the balance is just a matter of providing a block number with the eth_call call. (I believe this is available via web3.js too.) – user19510 Jan 15 '18 at 1:30
  • 1
    Indeed, you can provide a block number to any method call in web3.js. In this case, you'll be calling balanceOf on the token contract. – user19510 Jan 15 '18 at 1:32

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) by just running a SUM() of account balances changes between blocks 1 - end block.

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.

  • You can view the list of the particular token holders on etherscan under the Holders tab for example here etherscan.io/token/…. Also, if you view the Analytics tab for its contract you will find useful information for the balance during the contract's start date to present like here etherscan.io/address/… – mzaidi Feb 6 '20 at 6:57
  • Also, Etherscan offers balance checker tool. You can access it by going to contract -> more info (displayed on the right) -> select check previous balance by clicking on the 3 dots and then select the date for checking the balance. For example here etherscan.io/…. Hope that helps. – mzaidi Feb 6 '20 at 9:52
  • Now there is an example available in web3.py documentation. – Mikko Ohtamaa Apr 20 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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