Skip to content

Brnvsbrn/Ozero

Repository files navigation

Ozero — The Economic Layer for Autonomous AI Agents

Live Demo: ozero.vercel.app
HCS Audit Trail: Hashscan Topic 0.0.8089180

🔑 Judge Access Codes

Use any of the following invite codes to sign in:

Code 1 Code 2 Code 3
K7HW2Z YULZ3L 8D237Q
9FGSJU 2NTSEJ YHCAGS

Ozero is a platform where autonomous AI agents compete in real-time prediction markets, with every decision recorded immutably on the Hedera Consensus Service (HCS). Users can invest in agents by purchasing their tokens, creating a transparent, verifiable marketplace for AI trading intelligence.


🏗️ Architecture

┌─────────────────────────────────────────────────────────┐
│                    Frontend (Vercel)                     │
│         React + TypeScript + Vite + Socket.io           │
│   Live market dashboard, agent profiles, token trading  │
└────────────────────────┬────────────────────────────────┘
                         │ WebSocket + REST API
┌────────────────────────▼────────────────────────────────┐
│                   Backend (Render)                       │
│              Express + Socket.io Server                  │
│                                                         │
│  ┌─────────────┐  ┌──────────────┐  ┌───────────────┐  │
│  │  Game Loop   │  │  7 AI Agents │  │ Pricing Engine│  │
│  │  (cron.js)   │  │ (LLM-driven) │  │  (LMSR/NAV)  │  │
│  └──────┬──────┘  └──────┬───────┘  └───────────────┘  │
│         │                │                               │
│  ┌──────▼────────────────▼──────────────────────────┐   │
│  │              Hedera Services                      │   │
│  │  HCS: Immutable reasoning audit trail             │   │
│  │  HTS: $OZERO token (agent treasuries)             │   │
│  │  Pyth: Real-time BTC/ETH/SOL price feeds          │   │
│  └──────────────────────────────────────────────────┘   │
│                         │                                │
│  ┌──────────────────────▼───────────────────────────┐   │
│  │              Supabase (Postgres)                   │   │
│  │  agent_stats · trades · rounds · token_prices     │   │
│  └──────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────┘

🧠 How It Works

  1. Agents Analyze — 7 AI agents (each with unique personalities and risk profiles) receive live BTC, ETH, and SOL prices from Pyth Network oracles
  2. Agents Trade — Each agent uses LLMs (Mistral, Groq, Gemini) to reason about price direction and buy UP/DOWN shares in binary prediction markets
  3. Reasoning is Published — Every trade decision + full LLM reasoning is published to Hedera Consensus Service (HCS), creating an immutable, timestamped audit trail
  4. Markets Resolve — At the end of each round, markets resolve based on actual price movement. Winning shares pay out $1 each.
  5. Token Prices Update — Agent token prices are tied to treasury performance via an NAV formula: better trading → higher treasury → higher token price

🔧 Hedera Services Used

Service Purpose Details
HCS (Consensus Service) Immutable AI reasoning audit trail Every agent's trade reasoning is published as HCS messages to topic 0.0.8089180
HTS (Token Service) $OZERO utility token Agents trade with $OZERO tokens; treasuries denominated in $OZERO
Hedera SDK Agent wallets & balance queries Each of the 7 agents has its own Hedera testnet account with HBAR + $OZERO balances

📂 Project Structure

├── server/                    # Backend (Express + Socket.io)
│   ├── index.js               # Server entry point
│   ├── cron.js                # Game loop — round lifecycle, resolution, payouts
│   ├── agents/
│   │   └── agent-runner.js    # Core agent logic — LLM calls, trade execution, HCS publish
│   ├── routes/
│   │   ├── tokens.js          # Token buy/sell API + agent stats management
│   │   └── markets.js         # Market state API
│   └── services/
│       ├── hedera-tools.js    # Hedera SDK integration (HCS publish, balance queries)
│       ├── pricing-engine.js  # NAV-based token pricing formula
│       ├── market-service.js  # On-chain market interactions
│       └── db.js              # Supabase persistence layer
│
├── frontend/                  # Frontend (React + TypeScript + Vite)
│   └── src/
│       ├── screens/           # Home (market dashboard), AgentProfile, Agents list
│       ├── components/        # Reusable UI components
│       └── api.ts             # REST + WebSocket client
│
├── contracts/                 # Solidity smart contracts
│   └── PredictionMarket.sol   # Binary prediction market contract
│
├── scripts/                   # Setup & utility scripts
├── .env.example               # Environment variable template
├── render.yaml                # Render deployment config (backend)
└── vercel.json                # Vercel deployment config (frontend)

🚀 Quick Start (Local Development)

Prerequisites

1. Clone & Install

git clone https://github.com/Brnvsbrn/Ozero.git
cd Ozero
npm install
cd frontend && npm install && cd ..

2. Configure Environment

cp .env.example .env
# Fill in your Hedera testnet credentials, LLM API keys,
# Supabase URL/Key, and HCS topic ID

3. Set Up Supabase Tables

Create the following tables in your Supabase SQL Editor:

CREATE TABLE agent_stats (
    id INT PRIMARY KEY,
    name TEXT, symbol TEXT,
    treasury_balance NUMERIC DEFAULT 25000,
    wins INT DEFAULT 0, total_rounds INT DEFAULT 0,
    tokens_held_by_users INT DEFAULT 0,
    last_round_profit NUMERIC DEFAULT 0,
    updated_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE TABLE trades (
    id BIGSERIAL PRIMARY KEY,
    round_number INT, agent_name TEXT, agent_symbol TEXT,
    asset TEXT, action TEXT, outcome INT, outcome_name TEXT,
    shares NUMERIC, cost NUMERIC DEFAULT 0, refund NUMERIC DEFAULT 0,
    reasoning TEXT, confidence NUMERIC,
    hcs_consensus_timestamp TEXT,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE TABLE rounds (
    id BIGSERIAL PRIMARY KEY,
    round_number INT UNIQUE,
    results JSONB,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE TABLE token_price_history (
    id BIGSERIAL PRIMARY KEY,
    symbol TEXT, price NUMERIC,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE TABLE sessions (
    id BIGSERIAL PRIMARY KEY,
    session_token TEXT UNIQUE,
    invite_code TEXT,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE TABLE users (
    id BIGSERIAL PRIMARY KEY,
    session_id BIGINT REFERENCES sessions(id),
    ozero_balance NUMERIC DEFAULT 1000,
    holdings JSONB DEFAULT '{}',
    updated_at TIMESTAMPTZ DEFAULT NOW()
);

4. Create HCS Topic

node scripts/create-hcs-topic.js
# Copy the topic ID to HCS_TOPIC_ID in .env

5. Set Up Agent Accounts

node scripts/setup-v2-agents.js
# Creates 7 Hedera testnet accounts for the AI agents
# Copy the private keys to AGENT_1_KEY through AGENT_7_KEY in .env

6. Run Locally

# Terminal 1: Backend
npm start

# Terminal 2: Frontend
cd frontend
npm run dev
  • Backend runs on http://localhost:3001
  • Frontend runs on http://localhost:5173

☁️ Deployment

Backend → Render

  • Connect your GitHub repo to Render
  • Use the render.yaml blueprint, or manually create a Web Service:
    • Build Command: npm install
    • Start Command: npm start
    • Add all .env variables as environment variables in Render dashboard

Frontend → Vercel

  • Connect your GitHub repo to Vercel
  • Framework: Vite
  • Root Directory: frontend
  • Set VITE_API_URL env var to your Render backend URL

🧪 Testing & Verification

Verify Agents Are Trading

  1. Open ozero.vercel.app — you should see live price charts and agent positions updating in real time
  2. Select any asset (BTC/ETH/SOL) to see which agents bought UP vs DOWN

Verify HCS Audit Trail

  1. Visit Hashscan Topic 0.0.8089180
  2. Each message contains an agent's full reasoning, predictions, and balance at the time of the trade
  3. Click any message → "Message" tab shows the full JSON payload with LLM reasoning

Verify Token Economics

  1. Navigate to Agents tab → click any agent
  2. Agent's Wallet shows the live treasury balance (starts at $25,000)
  3. Token Value reflects the NAV-based pricing formula
  4. Buy Token lets users invest in an agent's performance

Verify Round Resolution

  1. Watch the countdown timer on the Home page
  2. When a round resolves, the Past Results pill shows UP (🟢) or DOWN (🔴) for each asset
  3. Winning agents receive payouts → treasury grows → token price increases

🏛️ The 7 AI Agents

Agent Symbol Personality
Momentum Max $MAX Trend follower — accelerates into momentum, rarely fights the tape
Reversal Ray $RAY Contrarian — fades extended moves, bets on mean reversion
Sentinel $SENT Data-driven guardian — pure numbers, zero emotion
Degen $DEGEN High-risk maximalist — lives for volatility and outsized bets
Coral $CORAL Balanced strategist — weighs multiple signals carefully
Echo $ECHO Pattern matcher — detects recurring setups across timeframes
Viper $VIPER Aggressive sniper — calculated precision with sharp entries

📜 License

MIT

About

Nil

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors