title: Why is blockhash not safe for random numbers?
body: <p>I'm thinking of a smart contract for a casino type game that looks like this:</p>
  <ul>
  <li>A &quot;roll&quot; function, which stores some input parameters (eg the user's bet), and the block number</li>
  <li>A &quot;verify&quot; function, which takes the previously stored roll, and uses the hash of the block that came after the roll as a random number, and verifies if the user won their bet</li>
  </ul>
  <p>The solidity docs say:</p>
  <blockquote>
  <p>Do not rely on block.timestamp, now and blockhash as a source of randomness, unless you know what you are doing.
  Both the timestamp and the block hash can be influenced by miners to some degree.</p>
  </blockquote>
  <p>But isn't the whole point of a PoW blockchain that the miners <strong>can't</strong> control the block hash? If they could, wouldn't they be able to do double spend attacks, or simply &quot;steal&quot; all the block rewards for themselves?</p>