Understanding SparkBet's provably fair gaming protocol
How we ensure provably fair outcomes
When you create a game, you choose "heads" or "tails". Your choice is combined with a random 32-byte nonce and hashed using SHA256. Only this hash is submitted to the blockchain, making your actual choice cryptographically hidden.
Your opponent joins the game and can see your commit hash but cannot determine your actual choice. They make their own choice and commit it the same way.
Both players reveal their choice and nonce. The smart contract verifies that each revealed choice matches the original commit hash. If they match, the winner is determined. If either player tries to cheat by changing their choice, the hash won't match and they forfeit.
Why this works: It's cryptographically impossible to find a different choice + nonce combination that produces the same hash. Once committed, you cannot change your decision.
Trustless fund management
When both players join a game, their bet amounts are locked in a 2-of-2 multisig address using Partially Signed Bitcoin Transactions (PSBTs). This means:
Escrow Flow:
Your funds are never stuck
SparkBet includes multiple timeout mechanisms to ensure your funds are never permanently locked:
If opponent doesn't join within 5 minutes, game expires and creator can reclaim their commit.
If a player doesn't reveal within 5 minutes after both commits, they forfeit and the other player wins.
If cooperative payout fails, after ~144 blocks (~24 hours) either player can claim refund via the CLTV-locked path in the escrow.
Important information before playing