Ethereum Blockchain is a deterministic Turing machine, meaning there is no randomness involved. If there was a random opcode in place, all miners would obtain different results and the network would be unable to reach a consensus.

There are currently several approaches for generating random numbers:

  • Use an external service through Oraclize: The problem here is that the service is centralized. Therefore, we have to trust the server (random.org, Wolfram Alpha, etc...) generating random numbers.
  • RANDAO: A DAO working as RNG. The problem here is mainly with the speed of obtaining the random number, and the transaction fees.
  • Use Blockhash: The problem with this approach is that miners can cheat and influence the value.
  • What is the best way to generate random numbers on-chain? It would be ideal if we can assign each listed approach to potential decentralized applications.

    More Elie Kfoury's questions See All
    Similar questions and discussions