I'm quite new to Ethereum so forgive my lack of detail and awareness in this question.

I've seen some gambling applications built on Ethereum and I'm wondering how the network agrees on the outcome of a random process to be included in the blockchain. Because of course, if a contract produces random outcomes it will have a different outcome each time it is run..



The contract provide deterministic outputs there is no rand function in the smart contract. you could try to write your own rand function using for example the block time stamp as a base. However, for the vdice.io, I've looked(just a glance) into the code i've found they use an oracle(external source) to get a random value:

 bytes32 myid = oraclize_query("URL", "json(https://api.random.org/json-rpc/1/invoke).result.random.data.0","BBX1PCQ9134839wTz10OWxXCaZaGk92yF6TES8xA+8IC7xNBlJq5AL0uW3rev7IoApA5DMFmCfKGikjnNbNglKKvwjENYPB8TBJN9tDgdcYNxdWnsYARKMqmjrJKYbBAiws+UU6HrJXUWirO+dBSSJbmjIg+9vmBjSq8KveiBzSGmuQhu7/hSg5rSsSP/r+MhR/Q5ECrOHi+CkP/qdSUTA/QhCCjdzFu+7t3Hs7NU34a+l7JdvDlvD8hoNxyKooMDYNbUA8/eFmPv2d538FN6KJQp+RKr4w4VtAMHdejrLM=", ORACLIZE_GAS_LIMIT + safeGas);
| improve this answer | |

There is no true randomness in contracts.

In this case, the contract is requesting that Oraclize fetch a random number from random.org. You are trusting both that random.org is honest, and that Oraclize doesn't call random.org several times looking for numbers that benefit it.

| improve this answer | |
  • Wasn't that this super serious bug in blockchain.info wallet pulling random numbers from random.org? Just had to post it here. :-) – Afr Jan 10 '17 at 9:24
  • Yup. Now they have a diverse pile of servers pulling entropy from a variety of places to ensure there is proper entropy across all wallets generated on all devices. It's super interesting. – tayvano Jan 10 '17 at 11:52
  • That's not exactly true as, depending on the specific API (and specifically in this case), you can look at the number of requests sent via that API key and verify that Oraclize didn't send more than planned! – Thomas Bertani Jan 11 '17 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.