> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inco.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Incasino

> A confidential on-chain casino with six games, powered by e.rand()

[Incasino](https://github.com/Inco-fhevm/incasino) is a confidential on-chain
casino built on Inco Lightning. Six games in one contract: Coin Flip, Dice,
Mines, Plinko, Rock Paper Scissors, and Slots. You bet native test ETH on Base
Sepolia, with no token or deposit step.

<Card title="Play the live demo" icon="dice" href="https://incasino.vercel.app">
  incasino.vercel.app, running on Base Sepolia.
</Card>

Where the [ConfidentialDeck template](/games/confidential-deck) shuffles a deck,
Incasino leans on the other core randomness primitive: `e.rand()`. It is the
cleanest place to see the play-then-settle pattern that every asynchronous Inco
game uses.

## The play-then-settle pattern

Inco has no synchronous on-chain decryption, so a round is always two
transactions:

```
play...(...)   lock the wager (sent as ETH), draw a secret seed with e.rand()
settle(gameId, attestation, signatures)
               submit the covalidator attestation, decode the seed, pay out
```

The seed is drawn confidentially and revealed only at settlement, so the outcome
cannot be known or front-run while the bet is live. The contract verifies the
covalidator-signed attestation before paying, so a player cannot forge a win.

## The six games

One `Casino.sol` holds the ETH bankroll and all six games. Each has its own
`play*` entry point; a single `settle` routes by game kind.

| Game                | Entry point                                      |
| ------------------- | ------------------------------------------------ |
| Coin Flip           | `playCoinFlip(wagerPerRound, isHeads, rounds)`   |
| Dice                | `playDice(guess, isOver, wagerPerRound, rounds)` |
| Mines               | `playMines(points, numMines, wager)`             |
| Plinko              | `playPlinko(wagerPerRound, rounds)`              |
| Rock Paper Scissors | `playRPS(action, wagerPerRound, rounds)`         |
| Slots               | `playSlots(wagerPerRound, rounds)`               |

Bets are capped at `MAX_WAGER_PER_ROUND = 0.0005 ether`, and quick games run up to
`MAX_ROUNDS = 10` rounds in one transaction. Payouts carry a small house edge
baked into the multiplier (for example Coin Flip pays 1.98x, a 2% edge).

## Deployed contract (Base Sepolia)

One verified contract holds the bankroll and every game. Chain id 84532.

| Contract | Address                                                                                                                              |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Casino   | [`0x5b5d7d4ad82bac6419c205c395fd208901592357`](https://sepolia.basescan.org/address/0x5b5d7d4ad82bac6419c205c395fd208901592357#code) |

The owner funds and withdraws the bankroll from the `/owner` page.

## Running it

```
contracts/   Solidity Casino contract, tests, deploy script
client/      Next.js frontend (wagmi + RainbowKit + viem)
```

```bash theme={null}
git clone https://github.com/Inco-fhevm/incasino.git

# contracts
cd incasino/contracts && npm install
cp .env.example .env          # set PRIVATE_KEY_BASE_SEPOLIA
npm run compile
npm run deploy:baseSepolia    # deploys and funds the bankroll
npm test

# frontend
cd ../client && npm install && npm run dev
```

Connect a wallet on Base Sepolia, grab test ETH from a faucet, and play.

## Honest note

This is a testnet build. Bets are capped low and the bankroll is a single
owner-funded contract, so it is a worked example of the play-then-settle pattern
and confidential randomness, not a production casino.
