I just saw this answer that informed me that block hashes were not a reliable source of randomness. In what situation are block hashes not a reliable way to obtain randomness?

2 Answers 2


Block hashes are not a reliable source of randomness in situations where the miner that has mined a block at that height, or a subsequent miner with the choice of whether to mine on top of that block, has an incentive to try to alter the result. For example, if you're making a lottery, a miner can make a bet, mine the block whose hash will settle it, and throw it away if the block would make them lose the bet.

The miner can either discard a block they would otherwise have broadcast, or ignore a block they would otherwise have mined on top of. Doing these things has a cost to the miner; Discarding a block means you lose the block reward and fees that you would otherwise have got, and not mining on top of a valid block increases the chances that your next block will be orphaned. In the former case the loss is roughly equivalent to the lost block reward and fees, although it can be more complicated if you also also combine other strategies like Selfish Mining where you might withhold a block for other reasons.

Since the cost to the miner of gaming a block hash is significant, it is often sufficiently secure to use for low-value contracts; The miner could game it if they wanted to, but gaming it would cost them more than they would stand to gain.


To sum up this thread :

Using a blockhash, timestamp, or other miner-defined value. Keep in mind that the miner has a choice of whether to publish a block or not, so they could conceivably have one chance at the prize per block they mine.

In other words, a miner can choose to only publish a block that he knows the seed of the said blockhash would yield him the result he wants.

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.