Bet AI: Hedera-based prediction market with AI signals, news analysis, and autonomous trading.
Bet AI — Hedera-Native AI-Driven Prediction Markets
Bet AI is an AI-powered decentralized prediction market built on Hedera Hashgraph, combining blockchain transparency with intelligent decision-making. Oracles can create prediction questions, users place bets using HBAR, and markets are automatically resolved on-chain, ensuring secure and verifiable settlements. It fuses parimutuel betting with AI-driven event probabilities, letting anyone create markets, place HBAR bets, and resolve outcomes on-chain, while AI continuously ingests news, synthesizes context, and outputs risk-adjusted confidence scores to guide decisions. A Hedera Agent adds true prompt-to-trade: type what you want, and the agent places the bet for you on-chain.
What sets Bet AI apart is its integrated AI agent, powered by Gemini, OpenAI, and DeepSeek, which analyzes news, sentiment, and market trends to generate confidence scores for outcomes. Users can view these insights on the Predict Output Page, while an autonomous mode allows the AI to trade on behalf of users, executing buy, sell, or hold actions based on signal strength. Additionally, Bet AI features on-chain parimutuel markets on Hedera (HBAR) with instant finality and low fees, a live dashboard that tracks user, agent, and joint performance with P/L over time, and a Hedera Agent that turns natural language prompts into signed on-chain bets.
Core Components
The smart contract (ParimutuelPredictionMarket) maintains a parimutuel pool per question with N outcomes, where placeBet(_questionId, _outcomeIndex, _amount) is payable in HBAR and requires msg.value == _amount. The addQuestion and resolveMarket functions are owner-only, and Claim distributes the total pool to winners pro-rata: userShare / totalWinnerPool × totalMarketPool.
Model 1: AI Signal Engine fetches news via NewsAPI for the selected question/event, builds a compact context of headlines, sources, timestamps, and brief summaries, uses an LLM (Groq) to evaluate likelihood and rationale, and applies a risk layer that modulates confidence (conservative/medium/aggressive) for capital sizing and thresholds. Envio is used for backtesting and for passing context to the backend Model 1. The AI agent is further powered by Gemini, OpenAI, and DeepSeek for sentiment and trend analysis.
Model 2: Hedera Agent is a LangChain-based agent with a place_bet tool wired to the Hedera SDK, understanding prompts like “Bet 5 HBAR on QID 12: outcome Yes” and signing/submitting Hedera ContractExecuteTransaction for placeBet. It is sandboxed with guardrails including max bet limits, whitelisted contracts, and confirmation mode.
Frontend consists of:
Prediction Market: browse markets, bet in HBAR, admin add/resolve (owner) Predict Output: fetch news context, generate signal, optional autonomous/agent actions Dashboard: KPIs for User/AI/Joint, P/L over time, trades, and recent investments
Backend uses Flask API exposing:
/api/news-context — returns NewsAPI context lines for a question /api/generate-signal — runs AI reasoning over news context /api/agent-chat — proxies prompts to the Node agent and returns structured output
End-to-End Flow
Create or pick a market: Admin adds a market question with outcomes (e.g., Yes/No) and an end time. Users view live markets from the contract.
Build context and get an AI view: In Predict Output, select a question, click “Fetch Context” to query NewsAPI for summarized headlines, then click “Generate Signal” for direction (BUY/SELL/HOLD), confidence score, and rationale. Risk settings adjust thresholds.
Place a bet (HBAR): Select an outcome; the app converts HBAR to tinybars and submits a ContractExecuteTransaction with _amount equal to msg.value.
Resolve and claim: After end time, the owner resolves the winning outcome. Winners claim proportionally from the total pool.
Track results: Dashboard aggregates metrics including net profit (USD), trade count, P/L over time, and recent investments, logging bets client-side and reconciling against resolved markets.
Market Mechanics
Parimutuel pools have no fixed odds; winners split the entire pool. Economics: totalMarketPool = sum of all outcome pools; payout(user) = userBetOnWinner / totalWinningPool × totalMarketPool. Bets lock until resolution to avoid insolvency; only the owner can resolve after endTime, with claims protected by idempotent hasClaimed.
Why Hedera
Finality within seconds, predictable low fees, fair ordering (gossip about gossip), high throughput, EVM support with HBAR as the native currency, and a simple, low-cost parimutuel UX for small and frequent bets.
Developer / Ops Details
Frontend: React + Vite + Tailwind; PredictionMarket fetches via ethers JSON-RPC and bets via Hedera SDK; PredictOutput handles question selection, news preview, signal generation, and agent chat; Dashboard uses chart.js for P/L and KPIs. Backend: Flask with NewsAPI, Groq LLM, and agent proxy spawning Node for hedera_agent.js. Solidity contract ParimutuelPredictionMarket implements addQuestion, placeBet, resolveMarket, claimWinnings, getMarket, questionCounter, and oracle functionality. Tinybars ensure HBAR correctness; admin methods are non-payable. Dev keys and environment variables are used for signing in dev; production should migrate to wallet signing or server-side signing with guarded policies.
User Experience
Markets page: pick a question, enter HBAR, click outcome, confirm. Predict Output: on-chain market picker → Fetch Context → Generate Signal → optional autonomous or agent actions. Dashboard: see net profit, trades, P/L curve, and recent bets for User, AI, and Joint strategies. Admin: tab visible to all; owners can add/resolve markets.
Security and Guardrails
No private keys in code; dev-only operator keys in frontend; production uses wallet signing or backend relay. Agent tool constrained to known contract and capped bet sizes. Clear feedback provided on invalid signatures, RPC throttling, or network misconfigurations.
Bet AI is a full-stack, AI-integrated decentralized prediction market that merges blockchain, AI, and web technologies to deliver an intelligent, transparent, and autonomous trading system. Built on Hedera Hashgraph, it combines parimutuel betting mechanics with real-time AI-driven decision-making, enabling users to place bets in HBAR while AI continuously analyzes market signals, news, and sentiment to generate confidence scores. Oracles can create prediction questions, users place bets, and markets are automatically resolved on-chain, ensuring verifiable settlements.
The platform’s architecture spans multiple layers working in sync. The frontend, built using React, Vite, and Tailwind CSS, provides an interactive UI for browsing markets, placing bets, and tracking profits. It includes a Dashboard showing user PnL and AI metrics, a Prediction Market Page listing all active questions with HBAR betting, and a Predict Output Page displaying AI-generated confidence scores with news context and sentiment insights. A notable implementation streams backend AI signal updates directly into Chart.js visualizations, giving users near-instant feedback on changing confidence levels.
The backend, implemented with Python and Flask, powers the AI and blockchain logic. It exposes three key APIs: /api/news-context for aggregating real-time sentiment via NewsAPI and Twitter feeds, /api/generate-signal for AI-driven probability scores using Gemini, OpenAI, and DeepSeek models, and /api/agent-chat for natural language interaction with the Hedera AI agent. To maintain efficiency, a lightweight caching system minimizes API calls while preserving real-time responsiveness.
At the core of the blockchain infrastructure is a Solidity-based ParimutuelPredictionMarket smart contract deployed on the Hedera Testnet (Chain ID: 296). It supports functions like addQuestion() for market creation, placeBet() for HBAR wagers (converted to tinybars), and resolveMarket() for oracle-based outcome settlement. The contract’s parimutuel logic ensures gas-efficient, multi-outcome betting with instant resolution through Hedera’s fast consensus.
The AI integration leverages Gemini, OpenAI GPT, and DeepSeek models for news, sentiment, and trend analysis, feeding into an autonomous mode where the AI can directly interact with smart contracts to execute buy, sell, or hold decisions based on live market signals and historical backtesting. Envio supports backtesting and backend context passing for Model 1, enabling seamless feedback loops between past performance and current prediction logic.
Envio HyperIndex acts as the system’s data pipeline, indexing Hedera contract events in real time via GraphQL. YAML-based configurations define event handlers for bets, resolutions, and claims, allowing instant synchronization between blockchain state and UI data. This underpins analytics, ensuring accurate dashboards and AI learning from historical trades.
The environment and security setup isolates sensitive data across layers. Frontend variables include Hedera account IDs and dev keys, while backend variables hold API credentials for NewsAPI, Groq, and Hedera. Keys are never exposed in version control, and only authorized oracles can resolve markets.
System flow: the frontend sends bet and signal requests to the backend; the backend aggregates news and computes AI confidence; the AI agent can optionally act autonomously to execute trades via smart contracts; Hedera finalizes and settles markets on-chain; the frontend dashboard reflects results in real time.
Partner technologies amplify the system’s strength: Hedera provides low-cost, high-speed finality; Groq and OpenAI deliver high-performance AI reasoning; NewsAPI and Twitter streams supply real-time sentiment; and Envio ensures blockchain data integrity.
Notable technical work includes cross-chain wallet handling via MetaMask with automatic Hedera switching, dual transaction systems (ethers.js for wallet, Hedera SDK for contracts), multi-tier JSON parsing for resilient AI responses, and autonomous AI execution bound by spending and confirmation guardrails. The platform’s unique fusion of AI-driven prediction, autonomous trading, and on-chain resolution makes Bet AI distinct—unlike typical systems that rely on manual or simulated betting, Bet AI allows the AI to act on real markets in near real-time, achieving a live feedback loop between intelligence and blockchain.

