PROVABLY FAIR
The operation of roulette is quite simple: once the 15-second countdown ends, a random number between 0 and 14 is generated and the result is announced. If the number is 0, it corresponds to yellow; if even, to black; and if odd, to pink.
import crypto from "crypto";const serverSeed = "1234";const publicSeed = "abcd";const nonce = 3;const seed = `ROULETTE-${serverSeed}-${publicSeed}:${nonce}`;const roll = getRollValue(seed);console.log("El resultado de la ruleta es", getRollColor(roll));function getRollValue(seed) {const hash = crypto.createHmac("sha256", seed).digest("hex");const h = Number.parseInt(hash.slice(0, 52 / 4), 16);const e = Math.pow(2, 52);return Math.floor(h / e * 15); }function getRollColor(rollValue) {const position = rollValue % 15;if (position === 0) {return 'YELLOW';}else if (position % 2 === 1) {return 'PINK';}else {return 'BLACK';}}