I'm tasked with determining the current distribution and live wallet stats of a particular ERC20 token. My experience with Ethereum development is largely with web3js, and have a strong idea on how I would approach this challenge with web3js in a nodejs application and a datastore (likely mongodb/redis for speed)

First, I would execute an initial synchronization up the "current block" utilizing web3.eth.filter watching the transfer log of the token contract while also watching all current transfer events to continuously update wallet state on parties involved in a transfer.

The mechanics of the following approach could be achieved by linearly calculating balances which is more strait forward but requires perfect math and multi-step synchronization (synchronize to block height at sync start [result.args.blockNumber <= start_block], secondary sync from start_block to current, and then watch every block). The other more convoluted way would be to build an index of addresses representing token holders (past and present) and then mass querying wallet balance through balanceOf() on several iterations that fix concurrency with each pass until it reaches acceptable margin-of-error, and finally having a watcher that updates balances for both token transaction parties. The former relies on linear calculation from start to finish whereas the latter relies on token contract balance state.

The first method is a bit easier in terms of development patterns and would by my likely choice, however, it seems to replicate the internal functionality of the contract which makes me wonder if I'm missing something entirely.

I've done a bit of research on this topic, but have come up empty handed. Maybe someone here has done something remotely similar and has some ideas on how to more efficiently acquire this data.

  1. An API that provides an export of distribution statistics for an ERC20 token
  2. An ERC20 centric library that simplifies this task
  3. A better way to aggregate this data with web3js
  4. Maybe better to use Python implementation of Web3?

I appreciate your time in reading this inquiry and any information you feel could help me in this journey.

  • Welcome to the Ethereum StackExchange! Some changes will help improve this question: focus on one question at a time, get very specific with each question, showing what you've tried so far. After splitting, some of these numbered questions will still not be appropriate for the site, because they are opinion-based, or too broad. For those, maybe try reddit.com/r/ethdev
    – carver
    Aug 31, 2017 at 16:55
  • The Augur project has to do a token migration of all accounts you can take a look at their scripts github.com/AugurProject/rep-migration
    – Ismael
    Aug 31, 2017 at 19:12


Browse other questions tagged or ask your own question.