For example, the contract saves the address when token created but after that token holder could send token or all tokens to another wallet.

Is it possible to find all wallet addresses of token holders which were created by my contract?

  • very cool.. Any example of 'IDS IN ARRAY' along with get function to see them?? I'm not so familiar with mapping can't really get my head around it. – user3252381 Oct 4 '16 at 6:50

All token transfers are performed by calling methods on your contract - so your contract can track balances and accounts in any way it wishes. If you're using the default arrangement of using a Solidity mapping, you will also need to keep a separate list of known account IDs in an array, so you can iterate over them.

  • How to get on outside contract? – Crossle Song Aug 29 '17 at 12:19

I have created a standalone open source tool which does the same.

  • Take a token contract address

  • Iterate over all ERC-20 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) - note that some balances may have become zero

You can find the command line application how to build the 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 watch the event as it happens within an app or within the token contract itself use:

mapping (uint => mapping (address => uint)) mappedAccounts;
  • That is not an event definition or an event emitter. Your answer is confusing. Perhaps you could add further information. – Thomas Clowes Aug 1 '17 at 13:49
  • I think he intended some kind of inverted index like mapping (address => uint) and then mapping (uint => address) to track addresses, like Nick Johnson said. – Ismael Aug 2 '17 at 2:31

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.