> ## 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.

# Inco for Games

> Build hidden-information games on Inco with the ConfidentialDeck template

Card games, raffles, and hidden roles all need the same thing: state that stays
secret until the rules say otherwise. A deck no one can predict. A hand only its
owner sees. A reveal at showdown that everyone can trust.

The [ConfidentialDeck template](https://github.com/Inco-fhevm/confidential-deck-template)
gives you that as one base contract. You inherit it and write only your game
rules. The shuffle, the private deals, the public reveals, and trustless
settlement come with it.

<Card title="Play the live demo" icon="gamepad" href="https://confidential-deck.vercel.app">
  All four games running on Base Sepolia. Connect a wallet and play.
</Card>

It is built on Inco Lightning v1. Inco is confidential compute for the EVM, not
FHE and not zk. "Secret" means the value is decrypted by Inco. "Provably fair"
means a covalidator attestation, not a proof.

## The five moves

Everything confidential is one call on `ConfidentialDeck`.

| Move            | Kit call                           | Under the hood                                         |
| --------------- | ---------------------------------- | ------------------------------------------------------ |
| Shuffle         | `_newShuffledDeck(n)`              | `e.shuffledRange(1, n+1, ETypes.Uint256)`, one Inco op |
| Draw            | `_draw()`                          | `e.getEuint256(deck, i)` plus auto `allowThis`         |
| Deal (private)  | `_dealTo(player)`                  | `card.allow(player)`, only they can decrypt it         |
| Reveal (public) | `_revealCard(c)` / `_dealFaceUp()` | `e.reveal(c)`                                          |
| Settle          | `_verifyValue(c, value, sigs)`     | `e.verifyDecryption(...)`, bound to the handle         |

## A whole game in about 15 lines

Inherit the kit and write only your rules. This is a simplified sketch; the real
`War.sol` adds matchmaking and settlement.

```solidity theme={null}
import {euint256} from "@inco/lightning/src/Lib.sol";
import {ConfidentialDeck} from "./kit/ConfidentialDeck.sol";

contract War is ConfidentialDeck {
    mapping(address => euint256) public myCard;

    function startRound() external payable {
        require(msg.value >= deckFee(52), "fee");
        _newShuffledDeck(52);
    }

    function draw() external {
        myCard[msg.sender] = _dealTo(msg.sender); // only the caller can peek it
    }
    // showdown: reveal both cards and settle with _verifyValue(...)
}
```

The frontend half reads cards back.

```ts theme={null}
import { getZap, peekMyCards, decodeCard } from "./client/incoDeckClient";

const zap = await getZap({ local: true });
const [c0] = await peekMyCards(zap, wallet, [handle]);
console.log(decodeCard(c0.value).label); // e.g. "A♠"
```

## What is in the box

<CardGroup cols={2}>
  <Card title="The ConfidentialDeck kit" icon="layer-group" href="/games/confidential-deck">
    The five confidential moves, the fees, and the rules that break new projects.
  </Card>

  <Card title="Worked examples" icon="gamepad" href="/games/examples">
    Four full games: War, Blackjack, Raffle, and Mafia.
  </Card>

  <Card title="Run it" icon="terminal" href="/games/quickstart">
    Install, test against a local node, deploy, and wire the frontend.
  </Card>

  <Card title="Source" icon="github" href="https://github.com/Inco-fhevm/confidential-deck-template">
    The full Hardhat project plus a Next.js demo dApp that plays all four games.
  </Card>
</CardGroup>

Building with an AI assistant? First set it up with [Build with AI](/build-with-ai),
the Inco agent skill that gives your assistant game-design sense. Then hand it the
template: the repo ships an `AGENTS.md` explaining the kit, the per-game privacy
model, and the frontend, so it can start fast.

## More Inco games

More full game apps, built on Inco but not on the deck template. Read them for
different confidential patterns.

<CardGroup cols={2}>
  <Card title="Incasino" icon="dice" href="/games/incasino">
    A six-game casino powered by `e.rand()`. The cleanest look at the
    play-then-settle pattern.
  </Card>

  <Card title="Mines" icon="bomb" href="/games/mines">
    Minesweeper with an encrypted board. Bombs placed by one shuffle, O(1) per
    click, attested cashout.
  </Card>

  <Card title="Hangman" icon="pen-nib" href="/games/hangman">
    The secret word stays encrypted on-chain. Every guess is resolved with core
    encrypted operations.
  </Card>
</CardGroup>
