user58: I want to create a transparent gambling/lotto site and use the block chain as entropy for lotto numbers, dice rolls, that kind of thing.  Would the transaction hash of the latest transaction be the best way to do this?  How often are transaction hashes created?  How would you, programmatically, access them?  

user324: If I may answer with my stack overflow hat on...
Here's how I'd draw a random number in way that no participant can influence the result of. 
Invite each player to pick a random number, x, and publish the hash(x). Once each hash has been published, each player should then reveal their x. With those x's, add them all together and hash the result. Use that final hash as the random value.
UPDATE: To work around the attack described in the comment below, use two rounds.

Each player selects a randon number, x, and reveals hash(x).
When all hashes have been revealed, each player reveals x.
All x's are combined and hashed. y=hash(all x)
Each player selects a new random number, z, and reveals hash(y+z).
When all of the second round of hashes have been revealed, each player reveals z.
All z's are combined and hashed. The result is used as the random value.

If the player has a prepared hash collision, they could only use it to select their prefered y value. This doesn't help because they would now need a way to find a collision where both inputs have the same prefix (y) which won't be known in advance. If you can do that in a timely manner, we all need a new hash function.
(I welcome comments. Its possible I've missed something else.)

user9: Only sort of. The transaction hash is specifically chosen because it is smaller than some number X (--> difficulty factor), so it isn't fully random. However, it has a lot of entropy in the sense that it contains input from a lot of different, not predictable transactions. So you could use this hash as a seed for your RNG.
If you just want to generate lotto numbers and dice rolls, I'd say it's more important that you find a good random number generator (RNG) - you won't reseed that often anyway.
If you wanted to use the hash as the random number directly, there's a problem: you only get one hash every ~10 minutes. Not all that many random numbers.

user22: The Bitcoin Lottery used an SHA256 hash of the two most recent blocks to generate random data and to my recollection there were not too many complaints about that method they chose. In any case it's only good for 256 bits of questionably random data every 10 minutes (20 if you don't reuse blocks) so there are probably better entropy sources, such as the setup they've built over at random.org

58: <p>I want to create a transparent gambling/lotto site and use the block chain as entropy for lotto numbers, dice rolls, that kind of thing.  Would the transaction hash of the latest transaction be the best way to do this?  How often are transaction hashes created?  How would you, programmatically, access them?  </p>
 324: <p>If I may answer with my stack overflow hat on...</p>

<p>Here's how I'd draw a random number in way that no participant can influence the result of. </p>

<p>Invite each player to pick a random number, x, and publish the hash(x). Once each hash has been published, each player should then reveal their x. With those x's, add them all together and hash the result. Use that final hash as the random value.</p>

<p>UPDATE: To work around the attack described in the comment below, use two rounds.</p>

<ol>
<li>Each player selects a randon number, x, and reveals hash(x).</li>
<li>When all hashes have been revealed, each player reveals x.</li>
<li>All x's are combined and hashed. y=hash(all x)</li>
<li>Each player selects a new random number, z, and reveals hash(y+z).</li>
<li>When all of the second round of hashes have been revealed, each player reveals z.</li>
<li>All z's are combined and hashed. The result is used as the random value.</li>
</ol>

<p>If the player has a prepared hash collision, they could only use it to select their prefered y value. This doesn't help because they would now need a way to find a collision where both inputs have the same prefix (y) which won't be known in advance. If you can do that in a timely manner, we all need a new hash function.</p>

<p>(I welcome comments. Its possible I've missed something else.)</p>
 9: <p>Only sort of. The transaction hash is specifically chosen <em>because</em> it is smaller than some number X (--> difficulty factor), so it isn't fully random. However, it has a lot of entropy in the sense that it contains input from a lot of different, not predictable transactions. So you could use this hash as a seed for your RNG.</p>

<p>If you just want to generate lotto numbers and dice rolls, I'd say it's more important that you find a good random number generator (RNG) - you won't reseed that often anyway.</p>

<p>If you wanted to use the hash as the random number directly, there's a problem: you only get one hash every ~10 minutes. Not all that many random numbers.</p>
 22: <p>The <a href="https://bitcointalk.org/index.php?topic=9812.0" rel="noreferrer">Bitcoin Lottery</a> used an SHA256 hash of the two most recent blocks to generate random data and to my recollection there were not too many complaints about that method they chose. In any case it's only good for 256 bits of questionably random data every 10 minutes (20 if you don't reuse blocks) so there are probably better entropy sources, such as the setup they've built over at <a href="http://www.random.org/" rel="noreferrer">random.org</a></p>
