Bethub.gg uses provably fair method, that doesn't allow us to manipulate the outcome once the game is started, below you can see how the hash is caluclated.
/* BEGIN VALUES YOU NEED TO CHANGE */
$hash = 'eb44276374a962e7790a691e54d337612594e67fe744514b8c16be288d6b246d';
$secret = 'zfbodo3TaO49YbCr';
$roll = '1';
/* END VALUES YOU NEED TO CHANGE */
$hash2 = hash('sha256', $secret . '-' . $roll);
if($hash == $hash2) {
echo 'Hash does match!';
} else {
echo 'Hash does not match!';
}
/* BEGIN VALUES YOU NEED TO CHANGE */
$hash = 'db8b8c2b5ffca3a2dc21d3da2155fbab5361e716cfad679ee95e4d45f0a0f165';
$secret = 'xHFed6szmurvfFNY';
$crash_at = '8.96';
/* END VALUES YOU NEED TO CHANGE */
$hash2 = hash('sha256', $secret . '-' . $crash_at);
if($hash == $hash2) {
echo 'Hash does match!';
} else {
echo 'Hash does not match!';
}
When a new round begins, we create a string of random characters called the server seed. This is displayed to the user immidiately.
When all bets are finalized, we check the EOS Blockchain for a number of a block that will be mined in the near future. The block number is displayed to the user immidiately after to avoid cherry-picking block IDs. After that block is mined, we use the hash from that block to create our final hash like this:
final_hash = sha256(`${server_seed}-${eos_block_hash}`);
From that hash, we use a simple function to get the winning ticket:
parseInt(final_hash.substr(0, 8), 16) % last_ticket
Where "last_ticket" is the total number of tickets in this round.
When a new coinflip is added, we create a string of random characters called the server seed. This is displayed to the user immidiately.
When another player joins the game, we check the EOS Blockchain for a number of a block that will be mined in the near future. The block number is displayed to the user immidiately after to avoid cherry-picking block IDs. After that block is mined, we use the hash from that block to create our final hash like this:
final_hash = sha256(`${server_seed}-${eos_block_hash}`);
From that hash, we use a simple function to get the winning ticket:
parseInt(final_hash.substr(0, 8), 16) % 100
If the ticket is equal or less than 50, it means that Player 1 has won (the one who created the game). If it's higher than 50, the winner is Player 2 (the one joining).
/* BEGIN VALUES YOU NEED TO CHANGE */
$hash = '85ac1834632901b3a540eb8634284003d0a40ecf7f48f76ea231b078b988728f';
$secret = 'B3v4a99eXWmbJQZRNGYV';
$roll = '85.88';
/* END VALUES YOU NEED TO CHANGE */
$hash2 = hash('sha256', $secret . '-' . $roll);
if($hash == $hash2) {
echo 'Hash does match!';
} else {
echo 'Hash does not match!';
}
/* BEGIN VALUES YOU NEED TO CHANGE */
$hash = '4843f4942c80300484f292487a5de1947eac550a47cb9a48690907dd6f5b39c1';
$secret = 'fUWwnJlveLzfu6XF';
$percentage = '69.04671153210356';
/* END VALUES YOU NEED TO CHANGE */
$hash2 = hash('sha256', $secret . '-' . $percentage);
if($hash == $hash2) {
echo 'Hash does match!';
} else {
echo 'Hash does not match!';
}
/* BEGIN VALUES YOU NEED TO CHANGE */
$hash = '1aa55ffe7e2988444540254b1f82b89c0b25ef5e1ba523a985e900704202cc55';
$secret = 'TldPofpK4Lh2yxqW';
$value = '1721249';
/* END VALUES YOU NEED TO CHANGE */
$hash2 = hash('sha256', $secret . '-' . $value);
if($hash == $hash2) {
echo 'Hash does match!';
} else {
echo 'Hash does not match!';
}
/* BEGIN VALUES YOU NEED TO CHANGE */
$hash = '7027dff0adc5fe4370f478c953e80dfb7e314969753e35ec632c037f232f27cb';
$secret = 'qPaClrroLEoolyt4';
$value = '1331113232';
/* END VALUES YOU NEED TO CHANGE */
$hash2 = hash('sha256', $secret . '-' . $value);
if($hash == $hash2) {
echo 'Hash does match!';
} else {
echo 'Hash does not match!';
}
/* BEGIN VALUES YOU NEED TO CHANGE */
$hash = '5c4a5782034b94ac1613d5d54da8775ff33ecf8479d751d0d9beae4d17811418';
$secret = 'P0lVemVXJAHTqpD3';
$value = '11121212121212';
/* END VALUES YOU NEED TO CHANGE */
$hash2 = hash('sha256', $secret . '-' . $value);
if($hash == $hash2) {
echo 'Hash does match!';
} else {
echo 'Hash does not match!';
}