I am trying to index blockchain data and I am thinking of what's a unique way to identify a block.

Is it enough to use block number as the primary identifier and is there a possibility that the data associated with block may change in the future?

If block number on its own is not enough, what other information should I include to form a unique constraint?

2 Answers 2


The best way is to use the block hash. For example block number 12551600 : https://etherscan.io/block/12551600

Hash : 0x1856e857565089091ef6ab0bb193b15302f293b33c5a432b8fbdb51cedfe1ad3

Block height is unique yes, but sometimes there is "re-org" on blockchain as you can see in this link :


For example, there is another block number 12551600 :

https://etherscan.io/block/12551600/f Note the extra "/f" at link's end.

Hash : 0x8e5fb29a9046c36dca0b1812f775b51c3e5170644e8e2177f867c7f8f53505d8

This block was not accepted. I think few times per hour when miners found block at the same time, and the stronger is picked by the network.

So take the hash because it's unique.


Yes, it is possible to have two blocks with the same number. However, only one will be valid. To determine which one is valid, you have to wait for a few blocks to be mined after the double blocks (this is called waiting for confirmation). The longest chain built on top of one of the two blocks will be considered the canonical chain.

Block number is not a unique identifier. The block hash is its unique identifier.

See this answer for a practical approach to indexing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.