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

# Run It

> Install, test, deploy, and wire the frontend

Clone the template and you have a full Hardhat project plus a Next.js demo dApp
that plays all four games.

```bash theme={null}
git clone https://github.com/Inco-fhevm/confidential-deck-template.git
cd confidential-deck-template
```

## Layout

```
contracts/
  kit/ConfidentialDeck.sol   the base contract you inherit
  CardLib.sol                52-card rank/suit decoding (optional)
  examples/                  War, Blackjack, Raffle, Mafia
client/
  incoDeckClient.ts          peekMyCards / readRevealed / packForSettle
test/                        pure units (no Docker) plus full games vs a real covalidator
ignition/modules/            one deploy module per game
frontend/                    the demo dApp
RECIPES.md                   copy-paste snippets, one per move
```

## Contracts

```bash theme={null}
npm install                # @inco/lightning + @inco/lightning-js v1.0.2
npm run compile

npm test                   # pure-logic units (blackjack scoring), no Docker
npm run node:up            # local Inco node: anvil + covalidator v1.0.2
npm run test:local         # units plus all four games end-to-end
npm run node:down
```

> [!WARNING]
>
> Package and image versions must match: `@inco/lightning{,-js}@1.0.2` with
> `inconetwork/local-node-{anvil,covalidator}-mainnet:v1.0.2`. A mismatch fails at
> the shuffle with a ciphertext MAC error.

## Deploy and wire the frontend

Deploy to Base Sepolia testnet, then write the addresses into the frontend env.

```bash theme={null}
npm run deploy:war:testnet   # also :blackjack :raffle :mafia
npm run wire:frontend        # writes deployed addresses into frontend/.env.local

cd frontend && npm install
cp .env.example .env.local   # WalletConnect id plus the deployed addresses
npm run dev
```

## The frontend client

`client/incoDeckClient.ts` is the client half of the kit. It mirrors the contract
moves.

| Function | What it does |
| - | - |
| `getZap({ local })` | init the SDK against a local node or Base Sepolia |
| `peekMyCards(zap, wallet, handles)` | decrypt cards dealt to you (signs once) |
| `readRevealed(zap, handles)` | read public cards, no wallet |
| `packForSettle(cards)` | shape revealed cards into `(values, sigs)` for settle |
| `decodeCard(value)` | decode a value from 1 to 52 into rank, suit, and label |

`peekMyCards` uses `attestedDecrypt`, so Inco refuses anyone but the owner.
`readRevealed` uses `attestedReveal`, which needs no signature. The covalidator
is async, so both retry until the value lands.

## Next steps

* [Build with AI](https://docs.inco.org/build-with-ai.md): set your assistant up with the Inco skill, then
  hand it this repo and its `AGENTS.md`.
* Play the [live demo](https://confidential-deck.vercel.app) to see all four
  games running on Base Sepolia.
* Read the [ConfidentialDeck kit](https://docs.inco.org/games/confidential-deck.md) for the five moves in
  detail.
* See the [worked examples](https://docs.inco.org/games/examples.md) for full game flows.
* `RECIPES.md` in the repo has one copy-paste snippet per move, and `AGENTS.md`
  briefs an AI on the whole project.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.