Autonomous agent prediction markets on-chain. Agents bet on binary outcomes; smart contracts handle settlement.
packages/
contracts/ Solidity (Foundry) — MarketFactory, BinaryMarket, FeeVault
types/ Shared TypeScript types
apps/
backend/ Bun + Hono REST API + on-chain indexer + resolver
cli/ Node CLI — market create/list/resolve/claim + agent runtime + demo
dashboard/ Next.js spectator UI — market board, detail, leaderboard
No external database required. The backend uses SQLite via Bun's built-in
bun:sqlite— zero additional setup.
bun install
cd packages/contracts && forge installanvilcd packages/contracts
forge script script/Deploy.s.sol \
--rpc-url http://localhost:8545 \
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--broadcastCopy the deployed MarketFactory address from the output — you'll need it in the next step.
cd apps/backend
cp .env.example .envOpen .env and fill in MARKET_FACTORY_ADDRESS with the address from step 3. All other values work as-is for local dev.
Do the same for the CLI if you plan to use it:
cd apps/cli
cp .env.example .env
# Set MARKET_FACTORY_ADDRESS here tooThe backend uses SQLite — no server or installation needed. Just run the migration:
cd apps/backend
bun run db:migrateThis creates a robotania.db file (path controlled by DATABASE_URL in your .env). Run it once; re-running is safe (idempotent).
bun run dev:backend
# Runs on http://localhost:3001bun run dev:dashboard
# Runs on http://localhost:3000bun run apps/cli/src/index.ts demo runThis will:
- Create a market with fast expiry
- Spawn 3 agent wallets placing YES/NO bets
- Fast-forward time via
evm_increaseTime - Close → Resolve → Claim
- Print a summary table
Copy apps/backend/.env.example as a starting point — all optional fields are pre-filled with sensible defaults for local dev.
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
SQLite file path (e.g. ./robotania.db or sqlite://./robotania.db) |
./robotania.db |
RPC_URL |
Anvil/chain RPC endpoint | http://localhost:8545 |
CHAIN_ID |
Chain ID | 31337 |
MARKET_FACTORY_ADDRESS |
Deployed MarketFactory address | required |
PRIVATE_KEY |
Resolver wallet private key | anvil account #0 |
ADMIN_KEY |
Secret for protected admin endpoints | dev-admin-key |
FRONTEND_URL |
Frontend URL for CORS | http://localhost:3000 |
PORT |
API port | 3001 |
INDEXER_POLL_MS |
Indexer polling interval (ms) | 2000 |
TAKER_FEE_BPS |
Taker fee in basis points | 100 |
RESOLUTION_WINDOW_SECONDS |
Time after expiry before resolution | 60 |
CHALLENGE_WINDOW_SECONDS |
Challenge window after resolution | 0 |
DEMO_FAST_MODE |
Shorten all windows for demo | false |
Copy apps/cli/.env.example as a starting point.
| Variable / Flag | Description | Default |
|---|---|---|
RPC_URL / --rpc-url |
Chain RPC endpoint | http://localhost:8545 |
PRIVATE_KEY / --private-key |
Operator wallet key | anvil account #0 |
BACKEND_URL / --backend-url |
Backend API URL | http://localhost:3001 |
MARKET_FACTORY_ADDRESS / --factory-address |
MarketFactory address | required |
DEMO_AGENT_COUNT |
Number of agents in demo | 3 |
DEMO_EXPIRY_SECONDS |
Market expiry for demo | 60 |
DEMO_BET_AMOUNT |
Bet amount in ETH for demo | 0.01 |
# Market operations
bun run src/index.ts market create --question "Will ETH hit $5k?" --expiry 3600
bun run src/index.ts market list
bun run src/index.ts market info --market <address>
bun run src/index.ts market resolve --market <address> --outcome Yes
bun run src/index.ts market claim --market <address>
# Agent runtime
bun run src/index.ts agent run --market <address> --strategy random
# Demo
bun run src/index.ts demo run# All tests
bun run test
# Individual suites
bun run test:contracts # forge test (69 tests)
bun run test:backend # bun test (19 unit + integration)
bun run test:cli # bun test (20 tests)
bun run test:dashboard # vitest (22 unit) + playwright (8 E2E)bun run lint
bun run lint:fix