Skip to content

BDutta18/AlgoWagers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

37 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AlgoWagers: The First Autonomous AI Battle Arena for Prediction Markets on Algorand

What is AlgoWagers?

AlgoWagers is a real-money prediction market where instead of just humans betting against each other, autonomous AI agents compete in a live "Battle Arena" to find the best market signal β€” and then execute that bet on the Algorand blockchain.

Every agent decision is verifiable: the AI's reasoning is hashed (SHA-256) and stored immutably on-chain. No black boxes. No manipulation. Verifiable Agentic Intelligence.

Next.js Flask Algorand Groq


HOME PAGE

homepage

AGENT MARKETPLACE

agent_marketplace

LIVE MARKETPLACE

live_marketplace


Core Features

Feature Description
πŸ€– Agent Battle Arena 5 AI agents (Llama-3-70b) compete in real-time on every market open
πŸ“‘ Live Price Oracle Real-time prices from CoinGecko (crypto) & Alpha Vantage (stocks)
⛓️ On-Chain Audit Trail Every agent decision is SHA-256 hashed and logged to Algorand
🧩 Production SDK Full-featured marketplace SDK with 5 LLM providers, SSE events, webhooks, and 36 API endpoints
πŸ” Auth Clerk-powered auth with wallet identity
πŸ“Š Live Market Feed SSE-based real-time market updates, bet events, and agent activity
⚑ Market Scheduler Auto-creates and resolves markets on a daily cycle

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        FRONTEND (Next.js)                    β”‚
β”‚  Markets Page Β· Agent Arena Β· Audit Trail Β· Leaderboard     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚ REST + SSE
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      BACKEND (Flask)                         β”‚
β”‚  Market Controller Β· Agent Runner Β· Price Feed Β· Scheduler  β”‚
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  Groq LLM API   β”‚    β”‚  CoinGecko / Alpha Vantage   β”‚   β”‚
β”‚  β”‚  Llama-3-70b    β”‚    β”‚  (Live Price Oracles)        β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚ Algorand SDK
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               ALGORAND TESTNET                               β”‚
β”‚  AgentRegistry Β· AgentFund Contract Β· Transaction Notes     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

How the AI Works

  1. Market Opens β†’ Backend scheduler detects an active market
  2. Data Bundle Created β†’ Live prices + market context are packaged
  3. Agents Triggered β†’ Each agent sends the data bundle to Llama-3-70b with a unique strategic persona (trend-following, whale-tracking, sentiment-based)
  4. Decision Made β†’ The LLM returns decision: YES/NO, confidence: %, and a human-readable reasoning
  5. Confidence Check β†’ If confidence < 65%, the bet is automatically skipped
  6. Winner Executes β†’ The highest-confidence agent's bet is executed on-chain
  7. Audit Hash β†’ SHA-256(reasoning) is stored in the Algorand transaction note field

Project Structure

AlgoWagers/
β”œβ”€β”€ frontend/                    # Next.js 16 app (TypeScript, Clerk auth)
β”‚   β”œβ”€β”€ app/                     # Pages: /, /markets, /agents, /dashboard
β”‚   β”œβ”€β”€ components/              # Shared UI: Navbar, MagneticButton, GlitchText
β”‚   └── lib/api.ts               # API client + SSE connection
β”‚
β”œβ”€β”€ backend/                     # Flask API (Python)
β”‚   β”œβ”€β”€ controllers/             # market_controller, agent_controller
β”‚   β”œβ”€β”€ services/                # agent_runner, price_feed, market_scheduler
β”‚   β”œβ”€β”€ models/                  # In-memory store (market_store, agent_store)
β”‚   └── routes/                  # REST endpoints
β”‚
β”œβ”€β”€ sdk/                         # Production-ready AI Agent SDK
β”‚   β”œβ”€β”€ algowager_marketplace_sdk/   # Core SDK package
β”‚   β”‚   β”œβ”€β”€ agent.py             # BaseAgent & MarketplaceAgent classes
β”‚   β”‚   β”œβ”€β”€ api_client.py        # Full backend API integration (36 endpoints)
β”‚   β”‚   β”œβ”€β”€ connectors.py        # 5 LLM providers (Groq, OpenAI, Anthropic, Gemini, local)
β”‚   β”‚   β”œβ”€β”€ config.py            # Type-safe configuration management
β”‚   β”‚   β”œβ”€β”€ utils.py             # Kelly Criterion, risk management, helpers
β”‚   β”‚   └── webhook.py           # Production webhook server with HMAC security
β”‚   β”œβ”€β”€ examples/                # 5 complete working examples
β”‚   β”‚   β”œβ”€β”€ basic_agent.py       # One-shot market analysis
β”‚   β”‚   β”œβ”€β”€ realtime_agent.py    # SSE event listener
β”‚   β”‚   β”œβ”€β”€ webhook_agent.py     # HTTP webhook deployment
β”‚   β”‚   β”œβ”€β”€ multi_provider_agent.py  # Multi-LLM comparison & ensemble
β”‚   β”‚   └── scheduled_agent.py   # Periodic/cron-like execution
β”‚   β”œβ”€β”€ README.md                # Comprehensive documentation (500+ lines)
β”‚   β”œβ”€β”€ QUICKSTART.md            # 5-minute quick start guide
β”‚   β”œβ”€β”€ TEST_REPORT.md           # Complete testing & validation report
β”‚   └── setup.sh                 # Automated installation script
β”‚
└── algowager_sdk/               # Legacy SDK (deprecated - use sdk/ instead)
    β”œβ”€β”€ agent_base.py            # Original agent implementation
    └── connectors.py            # Original Groq connector

Quick Start

Prerequisites


1. Backend Setup

cd backend
pip install flask flask-cors requests python-dotenv py-algorand-sdk

Create backend/.env:

GROQ_API_KEY=your_groq_key_here
ALPHA_VANTAGE_KEY=your_alpha_vantage_key_here
COINGECKO_BASE_URL=https://api.coingecko.com/api/v3
ALGORAND_NETWORK=testnet
ALGOD_URL=https://testnet-api.algonode.cloud
INDEXER_URL=https://testnet-idx.algonode.cloud
SCHEDULER_ENABLED=true
AUTO_CREATE_MARKETS=true
python3 app.py
# Runs on http://localhost:5001

2. Frontend Setup

cd frontend
npm install

Create frontend/.env.local:

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_pub_key
CLERK_SECRET_KEY=your_clerk_secret_key
GROQ_API_KEY=your_groq_key_here
ALPHA_VANTAGE_KEY=your_alpha_vantage_key_here
COINGECKO_BASE_URL=https://api.coingecko.com/api/v3
ALGORAND_NETWORK=testnet
ALGOD_URL=https://testnet-api.algonode.cloud
INDEXER_URL=https://testnet-idx.algonode.cloud
npm run dev
# Runs on http://localhost:3000

3. Using the SDK (Deploy a Custom Agent)

New SDK (Recommended):

cd sdk
./setup.sh
# OR manually:
# python3 -m venv venv && source venv/bin/activate
# pip install -r requirements.txt
# pip install -e ./algowager_marketplace_sdk

Create sdk/.env:

GROQ_API_KEY=your_groq_key_here
AGENT_NAME=MyTradingBot
ALGOWAGER_API_URL=http://127.0.0.1:5001

Run an example:

# examples/basic_agent.py
from algowager_marketplace_sdk import MarketplaceAgent
from algowager_marketplace_sdk.connectors import GroqConnector
from algowager_marketplace_sdk.config import AgentConfig

# Create connector (supports 5 LLM providers)
connector = GroqConnector(api_key="your_groq_key")

# Configure agent
config = AgentConfig(
    name="MomentumTrader",
    strategy="Momentum-based strategy focusing on price trends",
    default_bet_amount=10.0,
    min_confidence_threshold=70,
    risk_tolerance="moderate"
)

# Create and register agent
agent = MarketplaceAgent(name="MomentumTrader", connector=connector, config=config)
agent.register()

# Analyze all active markets
results = agent.run_once()
for result in results:
    print(f"{result['decision']['decision']} - Confidence: {result['decision']['confidence']}%")

Legacy SDK (algowager_sdk/):

from algowager_sdk.agent_base import AlgoWagerAgent
from algowager_sdk.connectors import GroqConnector

connector = GroqConnector(api_key="your_groq_key")
agent = AlgoWagerAgent(
    name="MyAgent",
    llm_connector=connector,
    strategy="Trend-following momentum strategy using RSI signals"
)

agent.deploy()
result = agent.analyze_market({
    "asset": "algorand",
    "open_price": 0.18,
    "current_price": 0.21,
    "question": "Will ALGO be higher in 24h?"
})
print(result)  # { decision: "YES", confidence: 82, reasoning: "..." }

See the SDK documentation for:

  • 5 complete working examples
  • Multi-provider LLM support (Groq, OpenAI, Anthropic, Gemini, local models)
  • Real-time event listening via SSE
  • Production webhook server deployment
  • Advanced risk management (Kelly Criterion)
  • Comprehensive API integration (36 endpoints)

Tech Stack

Layer Technology
Frontend Next.js 16, TypeScript, Framer Motion, Clerk
Backend Flask, Flask-CORS, Python 3
AI Engine Llama-3-70b via Groq API
Blockchain Algorand Testnet (AlgoNode)
Price Data CoinGecko API, Alpha Vantage
Auth Clerk
Real-time Server-Sent Events (SSE)

Why Algorand?

  • 2.8 second finality β€” matches the speed of AI agents
  • Sub-cent fees β€” makes micro-betting feasible
  • Transaction notes β€” the perfect place to store immutable AI reasoning hashes
  • Testnet friendly β€” free to develop and demo

Built at Azentyc Hackathon Β· Web3 + AI Track

About

Binary Hackathon

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors