I am going to get all ehtereum wallet addresses with positive balance. I tried to get addresses with a method to get transaction. I have got transaction from blocknumber(0~ Inf). Using web3 and following code:

block_number = 0
while True:
    tx = web3.eth.getTransaction(block_number)
    if not tx:
    block_number += 1

But above running time is too slow. If anyone know how to get all addresses by another way, please help me.


You could potentially query the blocks locally that would save you a significant amount of time assuming you have a full node.

  • Thanks. But your answer doesn't help me. I am going to all addresses of the ehtereum net. And I must know their balance. – Coder HHC Jul 5 '18 at 13:41

You are essentially trying to build a core component of a block explorer. Some related questions might be useful as background, like: How do block explorers actually work?

Note that even this brute-force approach of iterating all transaction recipients does not produce all account addresses, because of "internal transactions." See: How to get contract internal transactions

Even the subset of accounts you get by this iteration approach will be a very slow process. There's a lot of data to crunch through. But you can speed it up a bit by getting all the transactions in a block at once with:

block = w3.eth.getBlock(block_number, full_transactions=True)
for txn in block.transactions:
   # add txn.to to the set of recipients

API docs

That will at least save you a bunch of round-trip calls to your node, because you only have to call your node once per block rather than once per transaction.

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.