4

I'm working on some code right now that scans the blockchain block by block.

During that process I catalog new addresses as I encounter them in the TX list with each block.

Is there any other way to identify addresses? It seems to me you cannot know about an address (aside from being the actual account holder) until it receives a TX of some sort? Is that correct?

  • By "identify", do you mean that you want to link that account to a person? – galahad Oct 2 '16 at 21:21
  • @variable No. I mean identify whether or not an address is an active, actual account. As I said in my OP, I personally don't know of any other way to identify the existence of an account other than having it first show up as the recipient ("to") in a block's TX list. Is there any other way to identify accounts? – MrYukonC Oct 2 '16 at 22:00
3

There are 3 ways by which an address can come into existence, as far as Ethereum is concerned:

  • a transaction is sent to this address
  • a message call is made to this address within some contract
  • a block is mined where the address is specified as the coinbase (receiver of the block reward)
  • a SELFDESTRUCT is called with recipient being the address

To list all existing addresses you need to (in the corresponding order):

  • list all transactions, get the destination addresses from these transactions
  • execute all transactions, intercept all message calls, get the destination addresses from calls
  • list all blocks, get the coinbase addresses from these blocks

Scanning the Patricia trie of an Ethereum client wouldn't work because the addresses are hashed before they are written to the trie: Getting complete state of a smart contract

1

Indeed, an account "exists" only after it has received a transaction, as far as Ethereum is concerned.

In going through all the blocks you are in effect re-doing what your Ethereum node has done to build the state of the EVM. It is an expensive way to build an index of all addresses, especially that most addresses will show up many times.

So instead, how about remembering that the state of the EVM, or rather the state's Merkle root, is stored in each block. And the state is, in part, made of all the "existing" addresses.

So you would be better off scanning the Merkle tree; in fact a Patricia trie, which has truncated branches where addresses are missing. Check out this answer ELI5 How does a Merkle-Patricia-trie tree work?

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.