A fast-paced social deduction chat game where players try to spot the AI impostor hiding among humans, optionally betting on their guess. Your choices train the AI over time to become harder to detect.
SAMI drops you into short, intense chat rounds. After one minute of conversation, everyone votes on who they think is the AI. You can optionally place a bet before the round starts. If you guess right, you win — and your feedback helps SAMI learn to blend in even better.
- Join a room (optionally place a bet).
- Chat for ~2 minutes with other players (one is SAMI, the AI).
- Vote on who is the impostor.
- Reveal & Rewards: winners are paid out; results are logged to improve the AI through RLHF-style feedback.
Your guesses actively train the AI to mimic human behavior, making future rounds more challenging.
SAMI is a playful twist on the Turing Test: instead of a 1:1 interview, you compete in a multi‑player setting with incentives. This creates richer signals for training — and a much more fun experience.
- Fast social deduction in short chat rounds.
- Optional betting with on-chain building blocks.
- Adaptive AI (Eliza-based) improves using player feedback.
- Realtime web sockets for chat and state sync.
- Vite + Tailwind frontend for speed and DX.
- Frontend: Vite + React + Tailwind CSS
- Backend: Express + Socket.io
- AI: Eliza (character:
sami) - On-chain: Foundry (contracts), Wagmi, Viem, RainbowKit
- Optional Infra: Supabase (storage/auth), Caddy (reverse proxy)
Languages & tooling: TypeScript across the stack.
git clone https://github.com/fabian416/sami.git
cd sami
yarn installYou’ll typically need some secrets at the root.
Copy the template and fill in your values:
cp .env.example .envTwo terminals (recommended during development):
Terminal 1 — Backend
yarn backend:dev
# Expected: "Listening on :5001" (or your custom port)Terminal 2 — Frontend
yarn vite:dev
# Open http://localhost:3001 (or the printed URL/port)- Backend logs:
Listening on :5001(or your port) - Frontend opens at:
http://localhost:3001(or printed URL) - In devtools Network tab, requests target your local backend
- Chat works and messages flow (WS connected)
-
Frontend can’t call the API
CheckVITE_PUBLIC_API_URLinpackages/frontend/.env.local(scheme/port). -
WebSocket fails to connect
Ensure you’re usingws://(nothttp://). -
Environment variables not found
Ensure the correct.envfiles exist and that scripts read from them. Restart dev servers after any env change.
SAMI supports two connection modes to handle on-chain actions:
- Embedded (Beexo) — uses XO Connect to provide a built-in EIP-1193 provider without requiring a browser wallet.
- Normal wallet — uses the user’s wallet (Wagmi/RainbowKit) and wraps the connected WalletClient as an EIP-1193 provider.
Both flows are orchestrated in ContractsContext.tsx. The provider picks the mode via isEmbedded and wires up:
- an ethers
BrowserProvider+signer - contract instances for
USDCSimpleSAMIandUSDC - basic session hygiene (
accountsChanged/disconnectlisteners)
Usage (frontend):
import { useContracts } from "@/providers/ContractsContext";
const { contracts } = useContracts();
async function placeBet() {
const { sami, usdc, connectedAddress } = await contracts();
// e.g. ensure allowance, then call the game contract
// await usdc.approve(sami.getAddress(), amount);
}In Embedded mode the app instantiates an
XOConnectProviderwith the chain’s RPC/chainId; in Normal mode it adapts the connected wallet’sWalletClientto EIP-1193. Both paths converge on the same contract API so the gameplay UX stays identical.
sami/
├─ Caddyfile
├─ docker-compose*.yml
├─ package.json
├─ packages/
│ ├─ backend/ # Express + Socket.io server
│ │ ├─ src/
│ │ │ ├─ app.ts # Express app
│ │ │ ├─ server.ts # HTTP + WS bootstrap
│ │ │ ├─ sockets/ # socket events, handlers, session store
│ │ │ ├─ services/ # game & player services
│ │ │ ├─ routes/ # health + config routes
│ │ │ ├─ config/ # env, cors, supabase-client, contract-config
│ │ │ └─ utils/ # constants & helpers
│ │ └─ dist/ # built JS (do not edit)
│ ├─ frontend/ # Vite + React client
│ │ ├─ public/ # static assets (avatars, audio, GIFs, pdf)
│ │ ├─ src/
│ │ │ ├─ components/ # UI + game components
│ │ │ ├─ providers/ # Wagmi, Socket, Theme, Contracts contexts
│ │ │ ├─ utils/ # constants, settings, web3 utils
│ │ │ └─ views/ # screens (Home, etc.)
│ │ ├─ vite.config.ts
│ │ └─ tailwind.config.ts
│ ├─ eliza/ # AI character & glue code
│ │ ├─ characters/sami.character.ts
│ │ └─ src/ # eliza core hooks & clients
│ └─ foundry/ # smart contracts & scripts
│ ├─ contracts/ # USDCSimpleSAMI.sol, USDC.sol
│ ├─ script/ # deployment scripts
│ └─ deployments/ # deployed addresses (e.g., 80002)
└─ README.md
- Live: https://playsami.fun
- Follow on X: https://x.com/sami_ai_game
