Very interesting concept. What is the game that will be played? Is the game just a pure random winner of a betting round or is it a game that will be played by two players that require skills (like chess) that improves the odds of one team winning over another?
Yes, I think it's just random. But it would be nice if Dev confirms and explains which algorithm for randomization is used.
Also, may I suggest that you shorten the time period of each round. Or make two parallel rounds, one lasting 24 hours, other on only one hour or something.
Hi dE_logics, thank your for your feedback.
We have taken into consideration your suggestion, and you are right. The following rounds (from round #15) will last 1 hour each.
![Wink](https://bitcointalk.org/Smileys/default/wink.gif)
Here is how we generate the random number. Do not hesitate to ask for precisions if required.
Once the round is over : We ask oraclize for a random number between 1 and 2, let’s call this number OraclizeNumber
At the same time, we extract a pre-calculated secret random number for this round between 1 and 2, let’s call this number LocalNumber
IF OraclizeNumber = 1 AND LocalNumber = 1, THEN the winning team is “HEADS”
IF OraclizeNumber = 1 AND LocalNumber = 2, THEN the winning team is “TAILS”
IF OraclizeNumber = 2 AND LocalNumber = 2, THEN the winning team is “TAILS”
IF OraclizeNumber = 2 AND LocalNumber = 1, THEN the winning team is “HEADS”
How OraclizeNumber is determined We use the following query, inside the main smart contract (
https://etherscan.io/address/0xa464ce87d6ae47c23254f9bb431274cdc4164625 )
bytes32 queryId = oraclize_query("WolframAlpha", "RandomInteger[{1, 2}]”);
The response from Oraclize is publicly available, given the fact that they call our _callback function within the main contract
Example of _callback call :
https://etherscan.io/tx/0xe6427875539d02bfa38beec70da00a23b15725f3dd780e1cc5bb731c5a5ca98bHow LocalNumber is determined We have used the following javascript code to precalculate a large number of LocalNumbers for the future rounds.
https://gist.github.com/yoann-losbar/546a7dd73719a567d6b6edbd2ce0be30Example for round 703 (fake data, for illustrative purpose only)
“703": {
"winningChoice": 2,
"pub": "38c12dc83787c5a342dcf78e8c9cdc2b2b1cd48a8bc2e080b531c305084b65b5",
"salt": "440393a3-cfe0-4250-89df-b34530fc28f5"
}
The “pub” key 38c12dc83787c5a342dcf78e8c9cdc2b2b1cd48a8bc2e080b531c305084b65b5 will be publicly available as soon as the round starts.
The salt and the winningChoice are going to be kept secret until the round finishes.
As soon as the round is finished, the precaculated winningChoice and the salt key are going to be released.
You’ll then be able to verify that this local winning number (LocalNumber in our example) has not been modified by us since the beginning of the round by using the following code :
Pub = sha256(winningChoice + winningHashSalt);
Why are we using two random numbers from different sources to determine the final winning random number This system is trustless, as the true spirit of smart contracts/cryptocurrencies .
None of the 4 involved actors ( the Ethereum Miners, Oraclize, us, and you, players) can know in advance the outcome of a round, and bet using this knowledge.
Note : The verification page (providing pub hashes, salts and sha2 calculator will be available in the next days)
Do not hesitate if you have more questions
![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif)