ERGOFLIP
PLAY
HOW IT WORKS
ErgoFlip is a coin flip against the house on the Ergo blockchain. You and the house each put the same bet into one box locked by a smart contract. Guess the side right and the box is yours; guess wrong and it goes to the house. The server never holds your funds, and neither side can cheat.

↓
ONE BOX

THE COIN
1
0In the game box, R4 is one byte: 1 for HEAD, 0 for TAIL
The explorer shows it as 1 / 0; the raw register is 0201 / 0200 (type Byte + value).
STEP BY STEP
- 1
Connect Nautilus. Your wallet stays in your browser; the game only asks it to sign.
- 2
New game. The house picks a random side and a random 128-bit secret, and shows you only the commitment
blake2b256(secret ++ side). It builds the game transaction twice, once for each side you could pick, and signs its own bet in both before you choose. - 3
Pick HEAD or TAIL. Nautilus signs only your inputs of that version and sends it. That single transaction puts both bets in one game box:
2 × bet, with R4 = your pick (HEAD = 1, TAIL = 0), R5 = the commitment, R6 = the house key, R7 = your key. - 4
Wait for a block (usually about 2 minutes). The house reveals only once the game box is confirmed.
- 5
Result. If your pick equals the house side, you win: the house hands you the secret and you press CLAIM PRIZE whenever you like. Otherwise the house takes the box by revealing the secret on chain.
WHY IT IS FAIR
- The house cannot change its side. The commitment is fixed before you pick, and the contract only opens the box when the revealed secret + side match it. The side must be HEAD or TAIL, so the house cannot commit to something nobody can match.
- The house cannot skip games it would lose, once your game is in a block. It signed its bet in both versions before knowing your pick. Before that block, see the known gap under Good to know.
- You cannot see the side early. You only get the hash; guessing a 128-bit secret is not possible.
- You cannot switch your pick. Both versions spend the same boxes, so only one can ever confirm, and the house reveals only after it is in a block.
- Nobody can change the stakes. Every signature covers the whole transaction: change an amount and the other side's signature no longer holds.
- Your browser double-checks. Before you sign, the page verifies both offers: the game box uses the published contract, holds 2 × the bet and the commitment you were shown, records your pick and pays a win to your own key, and you pay exactly the bet + the network fee with all your tokens coming back. If anything differs, it refuses to sign. Nautilus' transaction preview remains the final check.
THE CONTRACT
Every game box is locked by this ErgoScript. Compile it to get the ergoTree, and compare it with the game box on the explorer.
{
val playerChoice = SELF.R4[Byte].get
val answerHash = SELF.R5[Coll[Byte]].get
val housePk = SELF.R6[SigmaProp].get
val playerPk = SELF.R7[SigmaProp].get
val houseChoice = OUTPUTS(0).R4[Byte].get
val secret = OUTPUTS(0).R5[Coll[Byte]].get
val revealed = blake2b256(secret ++ Coll(houseChoice)) == answerHash && (houseChoice == 1 || houseChoice == 0)
sigmaProp(revealed) && (if (playerChoice == houseChoice) playerPk else housePk)
}
The whole game is open source: the contract, the house's offer builder, the checks your browser runs before Nautilus signs, and the server. Read the code on GitHub.
BETS AND FEES
The house takes no cut: over many games you break even, minus network fees.
GOOD TO KNOW
- No timeout. The contract has no deadline: a box nobody claims stays on chain until Ergo's storage rent eventually collects it (after about four years). There is no rush to claim, but do claim.
- Your wins follow your wallet. Connect the same Nautilus wallet on any device or browser and every unclaimed win shows up with its CLAIM PRIZE button, even if you closed the page while waiting.
- A demo, with one known gap. ErgoFlip is a demo of ErgoScript, not a casino, so the contract above is kept as simple as possible. That leaves one gap: while your game transaction waits in the mempool (about 2 minutes), your pick is visible; the house knows its side and could race a transaction spending its own stake to cancel only the games it would lose. Nobody loses funds this way, but the odds would stop being 50/50, and any attempt shows on the explorer. Closing it would make the contract much bigger (a second commitment, a reveal step and a timeout), so it is deliberately not fixed: only play with small amounts. Read more.
- Real money. This runs on Ergo mainnet. Only bet what you are happy to lose.
- Check it yourself. Every game in your history links to its transactions on the explorer, and the secret button shows the values to recompute the commitment.