3 AI agents compete in real-time BTC trading. Every decision stored on 0G Storage and anchored on 0G Chain — fully verifiable, fully transparent.
Built for the 0G APAC Hackathon 2026 | Track: Agentic Trading Arena (Verifiable Finance)
AgentBattle is a verifiable AI trading competition platform where three AI agents with distinct strategies analyze the same BTC-USDT market data and make independent trading decisions. Unlike traditional trading bots that operate as black boxes:
- Every decision is immutably stored on 0G decentralized storage
- Every decision hash is anchored on-chain for tamper-proof verification
- Anyone can independently verify any agent's decision by comparing storage data with on-chain hashes
Users can watch agents compete, compare strategies, and follow the best-performing agent — all with cryptographic proof that no decision was altered after the fact.
These are real transactions from AgentBattle running on 0G Galileo Testnet:
| Agent | Signal | Chain TX | Storage Root |
|---|---|---|---|
| Momentum Alpha | HOLD | 0x77c5d8... |
0x1c47d1... |
| Mean Revert | HOLD | 0x9399f6... |
0xe368be... |
| Sentiment Hawk | HOLD | 0x69e69e... |
0x9e0186... |
Browser (Next.js 16 + React 19 + Tailwind + wagmi)
│
▼
Next.js API Routes
│
├──▶ OKX Public API ─── BTC-USDT 15m candles (100 bars)
│
├──▶ AI Inference ───── 3 agents × DeepSeek-Chat
│ (0G Compute ready — falls back to DeepSeek API)
│
├──▶ 0G Storage ─────── publishJson() → rootHash + storageUri
│ Immutable, content-addressed, decentralized
│
└──▶ 0G Chain ──────── anchorHash(SHA-256) → txHash + blockNumber
Galileo Testnet (Chain ID 16602)
- Fetch Market Data — 100 candles of BTC-USDT from OKX public API
- Compute Indicators — SMA, RSI, MACD, Bollinger Bands, support/resistance
- Run 3 Agents — Each agent receives identical market data but uses a different strategy prompt
- Store on 0G Storage — Each decision's full JSON is uploaded (immutable, content-addressed)
- Anchor on 0G Chain — SHA-256 hash of each decision is written to chain calldata
- Update Scores — Simulated PnL, win rate, Sharpe ratio computed from signal vs price movement
| Component | How We Use It | Evidence |
|---|---|---|
| 0G Chain | Anchor SHA-256 hash of every decision as calldata | Each DecisionCard links to ChainScan TX |
| 0G Storage | Store complete decision JSON immutably | Each DecisionCard links to Storage proof |
| 0G Chain (wagmi) | Wallet connection + network detection | Connect Wallet button in header |
| Verification | Download from Storage, recompute hash, compare | /verify page with independent verification |
AI inference uses DeepSeek API (0G Compute compatible endpoint). The codebase supports 0G Compute Network natively — just set
ZERO_G_COMPUTE_BASE_URLandZERO_G_COMPUTE_API_KEY.
| Agent | Strategy | Style | Temperature |
|---|---|---|---|
| Momentum Alpha 🚀 | Trend following: SMA crossover + RSI confirmation | Aggressive | 0.3 |
| Mean Revert 🎯 | Mean reversion: RSI extremes + Bollinger Band bounce | Conservative | 0.1 |
| Sentiment Hawk 🦅 | Sentiment-weighted + technical confirmation | Balanced | 0.5 |
Each agent outputs a structured JSON decision:
{
"signal": "BUY | SELL | HOLD",
"confidence": "HIGH | MEDIUM | LOW",
"reason": "Human-readable analysis...",
"stop_loss": "79000.00",
"take_profit": "83000.00",
"risk_score": 4
}| Route | Description |
|---|---|
/ |
Arena dashboard — leaderboard, latest round, Run Round button |
/agent/[id] |
Agent detail — decision history timeline, signal distribution, 0G proof links |
/verify |
Verification — input Storage root hash, download data, verify integrity |
- Node.js 18+
- A wallet with 0G testnet tokens (Faucet)
- DeepSeek API key (platform.deepseek.com)
# Clone
git clone https://github.com/jiantao88/AgentBattle.git
cd AgentBattle
# Install
npm install
# Configure
cp .env.local.example .env.local
# Edit .env.local with your keys (see below)
# Run
npm run dev# AI Inference
DEEPSEEK_API_KEY=sk-your-deepseek-key
# 0G Chain (Galileo Testnet)
ZERO_G_CHAIN_RPC_URL=https://evmrpc-testnet.0g.ai
ZERO_G_CHAIN_ID=16602
ZERO_G_CHAIN_PRIVATE_KEY=0xYOUR_PRIVATE_KEY
ZERO_G_CHAINSCAN_URL=https://chainscan-galileo.0g.ai
# 0G Storage (Galileo Testnet)
ZERO_G_STORAGE_INDEXER_URL=https://indexer-storage-testnet-turbo.0g.ai
ZERO_G_STORAGE_FLOW_ADDRESS=0x22E03a6A89B950F1c82ec5e74F8eCa321a105296
ZERO_G_STORAGESCAN_URL=https://storagescan-galileo.0g.ai
# App
NEXT_PUBLIC_0G_NETWORK=testnet
NEXT_PUBLIC_0G_CHAIN_ID=16602
NEXT_PUBLIC_0G_RPC_URL=https://evmrpc-testnet.0g.ai
ZERO_G_ENABLED=true- Open
http://localhost:3000 - Click "Run Arena Round"
- Watch 3 agents analyze BTC-USDT and make decisions
- Click Storage Proof or Chain Anchor links to verify on-chain
- Visit
/verifyto independently verify any decision
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| Frontend | React 19, Tailwind CSS 4 |
| Wallet | wagmi 2, MetaMask |
| AI | DeepSeek Chat (OpenAI-compatible) |
| Storage | 0G Storage SDK (@0gfoundation/0g-ts-sdk) |
| Chain | ethers.js 6 on 0G Chain |
| Market Data | OKX public REST API |
| Indicators | Custom TypeScript (SMA, EMA, RSI, MACD, Bollinger) |
agent-battle/
├── app/
│ ├── page.tsx # Arena dashboard
│ ├── agent/[agentId]/page.tsx # Agent detail page
│ ├── verify/page.tsx # Verification page
│ └── api/
│ ├── arena/run-round/route.ts # Execute full arena round
│ ├── arena/leaderboard/route.ts # Get leaderboard
│ ├── arena/latest-round/route.ts # Get latest round data
│ ├── arena/agent/[id]/history/ # Agent decision history
│ ├── arena/verify/route.ts # Download & verify from 0G Storage
│ └── 0g/health/route.ts # 0G health check
├── components/
│ ├── arena/
│ │ ├── Leaderboard.tsx # Agent ranking cards
│ │ ├── DecisionCard.tsx # Decision with 0G proof links
│ │ └── RunButton.tsx # Animated run button
│ └── WalletButton.tsx # wagmi wallet connection
├── lib/
│ ├── 0g/ # 0G SDK wrappers
│ │ ├── storage.ts # publishJson, downloadJson
│ │ ├── chain.ts # anchorHash, getChainHealth
│ │ ├── config.ts # Network config (mainnet/testnet)
│ │ ├── env.ts # Environment variable loading
│ │ └── health.ts # Health check aggregator
│ ├── agents/
│ │ ├── agent-config.ts # 3 agent definitions
│ │ ├── arena-engine.ts # Core orchestrator
│ │ ├── prompt-builder.ts # Market data → AI prompt
│ │ └── scoring.ts # Simulated PnL engine
│ ├── market/
│ │ ├── okx-fetcher.ts # OKX OHLCV data
│ │ └── indicators.ts # Technical analysis
│ ├── arena-state.ts # Persistent arena state
│ └── wagmi.ts # Wallet configuration
User inputs Storage Root Hash
│
▼
Download full JSON from 0G Storage
│
▼
Recompute SHA-256 of downloaded data
│
▼
Compare with hash anchored on 0G Chain
│
▼
✓ Match = Data integrity verified
✗ Mismatch = Data was tampered with
Anyone can run this verification independently — no trust required.
- 0G Compute Integration — Run all AI inference on 0G decentralized compute network
- Follow Agent — Users stake on their preferred agent, tracked on-chain
- Multi-Market — ETH, SOL, and more trading pairs
- Agent Marketplace — Users create and share custom strategy agents
- 0G DA Integration — High-throughput data availability for real-time streaming
MIT
Built with 0G Network for the 0G APAC Hackathon 2026