# What happens on hash collisions for, e.g., transactions, blocks, and contracts?

What happens on hash collisions for, e.g., transactions, blocks, and contracts?

What happens if, say, two transactions hash to the same value? In this case, we say that a hash-collision occured.

I've tried looking at the yellowpaper.io for an explanation, but can't really find the details.

Since the transaction hash serves as the transaction's identity, I don't see how Ethereum should allow multiple transactions with the same hash?

Transaction hashes are 64 hexadecimal characters. This means there are `16 ^ 64 = 115792089237316195423570985008687907853269984665640564039457584007913129639936` possible transaction hashes.

Currently, `77752349` Ethereum transactions have occurred. If you create a new transaction now, the chance of its hash colliding with a previous transaction is:

`77752349 / 16^64 =` `0.000000000000000000000000000000000000000000000000000000000000000000067148 %`

You are more likely to win the jackpot in a national lottery 8 times in a row.

This doesn't really answer your question, but just looking at the probability we have better things to worry about :-)

• Thanks, so if a collision occur, the EVM specification doesn't mention what should happen? Nov 5, 2017 at 10:25
• @Shuzheng It doesn't have to mention anything because the chance is so small. If you want to know for sure, you will have to read the source code, or ask a wallet developer. It may vary by implementation: geth may do something different from Parity. I would guess that the transaction would fail. In that situation, you would have to send a different transaction first to increment the nonce of your address. Then, you can do the transaction you wanted to do because it will have a different hash. Nov 5, 2017 at 10:35
• That makes sense to increase the nonce and try again. I don't agree that it doesn't have to mention it, since the probability is small. Would you like the whole blockchain to go into a corrupted state with small probability? Nov 5, 2017 at 10:37
• @Shuzheng There is a much larger chance that a huge electromagnetic eruption on the sun will wipe the blockchain from all hard drives. The specification doesn't have to mention this either. Nov 5, 2017 at 10:38
• OK! - you get a +1, and I will accept the answer, if no others can say what the specification suggests :-) Nov 5, 2017 at 10:41