A social deduction game where players try to identify which participant is controlled by an AI.
In this game:
- Users submit a prompt for the AI agent.
- Users join by paying 10 USDC.
- One random player is selected to have an AI agent chat on their behalf.
- Players chat for 1 minute, trying to determine who is the AI.
- A 10-second voting period follows where players vote on who they think is the AI.
- Players who correctly identify the AI split the prize pool.
The project consists of two main parts:
- Next.js frontend with OnchainKit for wallet integration
- Python WebSocket backend using OpenAI for AI responses
- Navigate to the
server
directory:
cd server
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install websockets openai python-dotenv
- Create a
.env
file in the server directory:
OPENAI_API_KEY=your_openai_api_key
- Start the WebSocket server:
python game_server.py
- Create a
.env.local
file in the root directory with your configuration:
NEXT_PUBLIC_ONCHAINKIT_API_KEY=your_onchainkit_api_key
NEXT_PUBLIC_ONCHAINKIT_PROJECT_NAME="BOT or NOT?"
NEXT_PUBLIC_WEBSOCKET_URL=ws://localhost:8765
- Install dependencies:
npm install
- Run the development server:
npm run dev
- Open http://localhost:3000 in your browser.
-
Join Game View:
- Players connect their wallet
- Submit their name and a prompt for the AI agent
- Pay 10 USDC to join (currently simulated)
-
Waiting Room:
- Players wait for the game to start (30-second countdown)
- Display of all players waiting
-
Chat Room:
- One player is randomly selected to be controlled by AI
- AI-controlled player cannot send messages, but the AI responds automatically
- Everyone chats for 1 minute
-
Voting Phase:
- Players vote on who they think is the AI
- 10-second voting period
-
Results Screen:
- Reveals who was the AI
- Shows vote results and winners
- Option to play again
- Frontend: Next.js, React, Tailwind CSS, OnchainKit
- Backend: Python, WebSockets, OpenAI API
- Blockchain Integration: Base chain via OnchainKit
For production deployment:
-
Deploy the WebSocket server to a secure environment:
- Ensure proper SSL/TLS setup for secure WebSocket connections (wss://)
- Update environment variables with production URLs
-
Deploy the Next.js frontend using Vercel or similar:
npm run build
-
Configure environment variables in your hosting provider.
MIT