3

I am looking for a command in Solidity (or other API) that allows me to see the wallets with balances in excess of x coins.

Anyone know how do do this?

Thanks

1 Answers1

2

I assume you mean all accounts with balances on Ethereum mainnet.

Scanning all accounts with your custom code is possible but quite an effort to code + run.

I would recommend to look at Etherscan's accounts list and their API.

UPDATE (based on question clarification): If you want to iterate through all token holders in your token contract. I assume you store balances in a mapping only so you can't iterate on all balances (solidity mappings are not iterable).

You could maintain a dynamic array with all addresses with balances but that would cost quite a lot of extra gas for each transfer etc. Even more importantly when you want to reward you would need to iterate through an unknown size array which could result to run over the block gas limit. You could make the reward in batches but it's getting overly complicated overall.

I would rather consider using a claim pattern instead. I.e. you would maintain the rewards and your token holders could claim their own reward on-by-one, calling the claim reward tx themselves.

szerte
  • 1,231
  • 1
  • 14
  • 32
  • I am looking to look at all balances for my own token (ERC20) ... I need to see who holds a certain amount to reward them. – Leor Hurwitz Jan 08 '18 at 11:44
  • 1
    Thanks for your update.

    Further question - how does this site do it?

    https://etherscan.io/token/Indorse#balances

    Here they have all holders sorted descending.

    If I could do that internally in my contract that would be incredible.

    – Leor Hurwitz Jan 09 '18 at 11:14