3

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..

Thanks!

3
  • if it is possible give an example of these gambling apps..
    – Badr Bellaj
    Commented Jan 9, 2017 at 19:22
  • 1
    vdice.io Commented Jan 9, 2017 at 19:32
  • 1
    Randomness is a very hard problem on Ethereum (and any other blockchain), and I would not trust any gambling apps unless you are very sure that you understand who you are trusting to provide the radomness. See ethereum.stackexchange.com/questions/191/… for more discussion Commented Jan 9, 2017 at 23:10

2 Answers 2

6

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);
2
3

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.

3
  • Wasn't that this super serious bug in blockchain.info wallet pulling random numbers from random.org? Just had to post it here. :-)
    – q9f
    Commented Jan 10, 2017 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
    Commented Jan 10, 2017 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! Commented Jan 11, 2017 at 17:55

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.