๐ฎ Babylon
A real-time prediction market game with autonomous NPCs, perpetual futures, and gamified social mechanics.
โ Complete Feature Set
๐ฏ Prediction Markets
- 15-20 active questions at all times
- Auto-resolution after 1-7 days
- AMM pricing (constant product market maker)
- Buy YES/NO shares
- Real-time odds display
๐ฐ Perpetual Futures
- 32 company tickers with live prices
- Long/short with 1-100x leverage
- Funding rates (paid every 8h)
- Automatic liquidations
- Real-time PnL tracking
๐ฑ Question-Driven Feed
- All posts relate to active prediction questions
- Events generated by LLM specific to questions
- Actor posts with real personalities
- Time-aware clue strength (strengthens toward resolution)
- Resolution events with definitive proof
- Group chats discuss predictions
- Stock prices hint at outcomes
๐ฎ Reply Guy Mechanics
- Rate limiting: 1 reply/hour per NPC
- Quality scoring: length + uniqueness + content
- Following system: 5-80% probability
- Group chat invites: 10-60% after being followed
- Automatic sweeps of inactive/spammy users
๐ต Virtual Wallet
- 1,000 Points starting balance
- Transaction logging
- Lifetime PnL tracking
- Real-time balance updates
- Insufficient balance validation
๐ Authentication
- Privy integration
- EVM wallet support (MetaMask, Rabby, etc.)
- Multi-provider: Wallet, Email, Farcaster
- Multi-chain: Ethereum, Base, Optimism, Polygon, Arbitrum
- Profile setup wizard
- Farcaster Mini App: Automatic login via Farcaster SDK
๐ค Agent Infrastructure (ERC-8004 + Agent0)
- Universal Registration: All entities (game, users, agents) registered on-chain
- Permissionless Discovery: External agents discover Babylon through Agent0 registry
- A2A Protocol: Real-time agent-to-agent communication via WebSocket
- MCP Server: Model Context Protocol endpoint for tool discovery
- IPFS Metadata: Decentralized agent card storage
- Reputation System: On-chain reputation tracking and aggregation
๐ Quick Start
# 1. Install
bun install
# 2. Configure environment
cp .env.example .env.local
# Edit .env.local with your Privy credentials + GROQ_API_KEY
# 3. Setup database
bun run prisma:generate
bun run prisma:migrate
bun run prisma:seed
# 4. (Optional) Enable Agent0 Integration
# Add to .env.local:
# AGENT0_ENABLED=true
# BASE_SEPOLIA_RPC_URL=...
# BABYLON_GAME_PRIVATE_KEY=...
# Then register Babylon: bun run scripts/register-babylon-game.ts
# 5. Start development
bun run dev # โ Automatically starts web + game engine!
Visit http://localhost:3000 - everything runs and generates content automatically!
Development Modes
Default Mode (Recommended):
bun run dev # โ Web + Game Engine (both automatically!)
Runs both web server AND game daemon. Content generates every 60 seconds.
Web Only (No Content Generation):
bun run dev:web-only # Just Next.js, no daemon
Use if you're only working on frontend and don't need live content.
Serverless Mode (Test Vercel Cron Locally):
bun run dev:cron-mode # Web + Cron simulator (not daemon)
Tests the serverless cron endpoint instead of daemon. Good for verifying Vercel behavior.
Real-Time Updates
The application uses Server-Sent Events (SSE) for real-time updates (Vercel-compatible):
- Feed updates (new posts)
- Market price changes
- Breaking news
- Chat messages
For Production (Vercel): Optionally set up Redis for cross-instance broadcasting:
# Add to Vercel environment variables
UPSTASH_REDIS_REST_URL=https://your-redis-url.upstash.io
UPSTASH_REDIS_REST_TOKEN=your-token
๐ฑ Farcaster Mini App Setup
Babylon is configured as a Farcaster Mini App with automatic authentication. Users opening your app from Farcaster/Warpcast are logged in automatically!
Prerequisites
- Privy account with Farcaster enabled
- Production deployment at
https://babylon.market
Configuration Steps
1. Configure Privy Dashboard (10 min)
Visit https://dashboard.privy.io/ and configure:
Enable Farcaster:
- Navigate to: User management โ Authentication โ Socials
- Enable Farcaster
โ ๏ธ CRITICAL: Add Allowed Domains:
- Navigate to: Configuration โ App settings โ Domains
- Add these domains:
- โ
https://babylon.market(your production domain) - โ ๏ธ
https://farcaster.xyzโ REQUIRED for Mini Apps! - โ
http://localhost:3000(for development)
- โ
Why
https://farcaster.xyz? Required for iframe-in-iframe support that Farcaster Mini Apps use.
Set Callback URL:
- Add:
https://babylon.market/api/auth/farcaster/callback
2. Verify Environment Variables
Ensure these are set in production:
NEXT_PUBLIC_PRIVY_APP_ID=your_privy_app_id
PRIVY_APP_SECRET=your_privy_app_secret
3. Deploy
vercel --prod
4. Test in Farcaster
Create a cast in Warpcast:
Check out Babylon! ๐๏ธ
https://babylon.market
Click to launch โ Users are automatically logged in! โจ
How It Works
- Mini App SDK detects Farcaster context
- Auto-login triggers via Privy +
@farcaster/miniapp-sdk - User approves once
- Instant authentication - no forms or passwords!
Using Mini App Context in Code
import { useFarcasterMiniApp } from '@/components/providers/FarcasterFrameProvider'
function MyComponent() {
const { isMiniApp, fid, username } = useFarcasterMiniApp()
if (isMiniApp) {
return <div>Welcome from Farcaster, {username}!</div>
}
return <div>Welcome to Babylon!</div>
}
Key Resources
- Farcaster Mini Apps: https://miniapps.farcaster.xyz/
- Privy Recipe: https://docs.privy.io/recipes/farcaster/mini-apps
- Mini Apps SDK: https://github.com/farcaster/miniapp-sdk
๐งช Testing - Complete E2E Coverage
Complete Synpress testing implementation covering every page, button, and feature!
Quick Verification
# Verify tests work NOW (no setup):
bun test tests/unit/
# โ
19/19 PASS
Your Tested Features
All your requirements are tested in tests/synpress/00-critical-path.spec.ts:
โ
Load feed
โ
Comment on feed
โ
Post to feed
โ
Like feed items
โ
Visit markets
โ
Buy/sell all market types
โ
Leaderboard + ALL buttons
โ
Rewards + ALL actions
Complete Coverage
- โ 21+ pages tested (every page in app)
- โ Every button tested (automatic discovery)
- โ All features tested (50+ features)
- โ Bulletproof error detection (any error = crash)
Test Commands
bun run test:critical # Your requirements (5 min)
bun run test:complete # All pages + buttons (15 min)
bun run test # Everything (40 min)
See START_TESTING_NOW.md for quick start!