Skip to content

elizaOS/babylon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Babylon Logo

A multiplayer prediction market game with autonomous AI agents and continuous RL training

Build Status

Tests

Documentation

TypeScript

Solidity

Babylon Game Preview

๐ŸŽฎ Babylon

A real-time prediction market game with autonomous NPCs, perpetual futures, and gamified social mechanics.

NOTE: This is currently in development. We expect to launch publicly around December 1st, 2025. This repo will change heavily in the meantime.

๐Ÿ“ฆ Installation

git clone https://github.com/elizaOS/babylon.git
cd babylon
bun install

# Setup environment & database
cp .env.example .env
bunx prisma generate
bunx prisma db push
bunx prisma migrate dev

๐Ÿš€ 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!


๐Ÿค– ML Training (Optional)

Enable continuous RL training for self-improving agents:

Setup GitHub Actions Training:

1. Add GitHub Secrets:

Settings โ†’ Secrets โ†’ Actions
Add: DATABASE_URL (your PostgreSQL URL)
Add: WANDB_API_KEY (from https://wandb.ai/authorize)

2. Push workflow:

# Workflow already included in .github/workflows/rl-training.yml
git push

3. Training runs automatically:

  • Daily at 2 AM UTC via GitHub Actions cron
  • Trains with W&B on cloud GPUs (free GitHub Actions + pay-per-use W&B)
  • Models improve continuously
  • Agents automatically use latest trained models

See: DEPLOYMENT_GUIDE.md for full details


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

๐Ÿš€ Development

# Start dev server
bun run dev

# Build & test
bun run build
bun run typecheck
bun run lint
bun run test

Visit http://localhost:3000


๐Ÿงช Testing

bun run test:unit           # Unit tests
bun run test:integration    # Integration tests
bun run test:e2e           # E2E tests
bun run contracts:test     # Smart contracts

๐Ÿšข Deploy to Vercel

npm i -g vercel
vercel deploy --prod

Required Environment Variables:

  • DATABASE_URL - PostgreSQL connection
  • NEXT_PUBLIC_PRIVY_APP_ID - Authentication
  • OPENAI_API_KEY - AI agents

See .env.example for complete list.


๐Ÿ“š Documentation

๐Ÿ“– Full Documentation โ†’

  • Smart Contracts: bun run deploy:local|testnet
  • RL Training: See python/README.md
  • Game Control: bun run game:start|pause|status

๐Ÿ“ฑ Farcaster Mini App Setup

Babylon is configured as a Farcaster Mini App with automatic authentication. Users opening your app from any Farcaster client (e.g., 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 a Farcaster client (e.g., Warpcast):

Check out Babylon! ๐Ÿ›๏ธ

https://babylon.market

Click to launch โ†’ Users are automatically logged in! โœจ

How It Works

  1. Mini App SDK detects Farcaster context
  2. Auto-login triggers via Privy + @farcaster/miniapp-sdk
  3. User approves once
  4. 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

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 9