BharatMarket
Protocol docs
Documentation overview
Oracle-powered prediction market protocol.
BharatMarket lets users and applications create, trade, settle, and embed prediction markets. This guide is organized with concepts first, then each user action, then integration and reference, mapped to the indexed backend, contracts, and oracle workers.
Introduction
Overview
BharatMarket is an oracle-powered prediction market exchange for binary event markets. Users create YES/NO markets, provide liquidity, trade outcomes, and redeem winning claims after deterministic on-chain settlement.
The live system currently focuses on crypto and cricket markets. Both use structured oracle metadata so the result is externally sourced, reproducible, auditable, and visible in the UI.
Verification
Public proofs
BharatMarket is intentionally inspectable: the source is public, the app is live, market actions are verifiable on Polygon Amoy, and indexed market data is exposed through public API routes.
GitHub repository
Public source code for the app, contracts, indexer, workers, SDK foundation, embeds, and documentation.
Live deployment
Production Vercel deployment connected to Polygon Amoy, indexed backend data, and wallet-native execution.
Polygon Amoy explorer
Verify market creation, trades, approvals, Chainlink requests, settlements, and redemptions on-chain.
Public market API
Database-backed market feed used by external products, embeds, and protocol integrations.
Concepts
BharatMarket 101
Market types
Supported markets
Crypto markets
LiveCoinGecko-backed price_above and price_below markets for BTC, ETH, SOL, and USDC-style outcomes.
Cricket markets
LiveCricAPI-backed winner markets using finished fixture data and deterministic team normalization.
Election markets
PlannedVisible as architecture only until verified, reproducible election result providers are added.
Lifecycle
Market lifecycle
Create Market
Trade YES / NO
Market Expires
Oracle Verification
On-chain Settlement
Redemption
Oracle layer
Structured oracle metadata
BharatMarket avoids arbitrary free-text settlement rules. Market creation encodes provider, category, external id, market type, settlement rule, verification source, and fallback details into a structured metadata payload.
{ category: 'crypto', provider: 'coingecko', marketType: 'price_above', externalId: 'ethereum', targetPrice: 5000}Settlement
Crypto settlement
Crypto markets use CoinGecko as the external provider and Chainlink Functions as the trusted fetch/normalization layer. Supported assets include bitcoin, ethereum, solana, and usd-coin style market rules.
Provider
CoinGecko market chart range endpoint
Market types
price_above, price_below
Output
YES or NO plus fetched settlement price
Persistence
Oracle event, provider payload, settlement price, and resolved market state
Settlement
Cricket settlement
Cricket markets use CricAPI-compatible fixture metadata. Winner markets resolve by comparing the official match winner against the selected YES team after the fixture is completed.
Provider
CricAPI match result endpoint
Market type
winner
Rule
selectedTeam must equal official match winner
Status
Live provider path; election remains future-only
Automation
Resolution automation
The resolution worker scans expired, unresolved, eligible markets from the database, performs prechecks, requests Chainlink Functions, records oracle lifecycle events, and avoids repeated spam through retry cooldowns. Sync endpoints are available for production schedulers.
market expires→ worker detects eligible market→ Chainlink Functions fetches provider data→ market resolves on-chain→ indexer syncs result→ frontend unlocks redemptionUsing the app
Pages and tools
Markets
Live and awaiting markets, indexed probabilities, category filters, top movers, and direct market entry.
History
Resolved and ended markets with outcome review and archive visibility.
Create
Structured market creation with oracle metadata, USDC fee approval, and wallet-native contract deployment.
My Account
Portfolio terminal for YES/NO/LP holdings, redeemable claims, open exposure, and book health.
Manage Markets
Creator-facing board for markets launched by the connected wallet.
Embeds
Partner-friendly board and market widgets backed by indexed BharatMarket data.
Docs
Protocol documentation, integration notes, current stage, and roadmap.
Creator flow
Create market
Creation is intentionally a two-step wallet flow: approve USDC for the creation fee, then create the market. This keeps ERC-20 allowance explicit and avoids hidden spending permissions.
Portfolio
Account and positions
The account center reads portfolio groups from BharatMarket’s indexed data layer and supplements wallet state where needed. It tracks YES, NO, LP holdings, redeemable claims, market status, and estimated value.
Widgets
Embeds
<iframe src="https://bharat-market-main.vercel.app/embed/board" /><iframe src="https://bharat-market-main.vercel.app/embed/market/0x..." />Integrate
Quickstart
SDK
SDK surface
createMarket({ category: 'crypto', asset: 'ETH', targetPrice: 5000 })buyYes({ market, amount: '10' })buyNo({ market, amount: '10' })addLiquidity({ market, amount: '100' })redeem({ market })Public API
Indexed endpoints
GET /api/public/marketsGET /api/public/markets/[address]GET /api/public/portfolio/[wallet]GET /api/public/oraclesWebhooks
Event model
market.createdtrade.executedliquidity.addedoracle.requestedoracle.completedmarket.resolvedReference
Contracts
MarketFactory
Creates CPMM-style YES/NO markets and collects the creation fee
Market
Handles trading, liquidity, settlement state, and redemption
ChainlinkFunctionsOracle
Requests provider-backed settlement and calls markets with deterministic outcome
USDC collateral
External collateral token configured by deployment environment
Reference
Indexer and database
The app is designed for smooth UX through PostgreSQL-backed indexed reads. Frontend dashboards consume backend API data first; direct RPC reads are used for wallet-sensitive or fallback state where appropriate.
Reference
Environment
DATABASE_URLINDEXER_RPC_URLNEXT_PUBLIC_MARKET_FACTORY_ADDRESSNEXT_PUBLIC_USDC_ADDRESSNEXT_PUBLIC_CHAINLINK_ORACLE_ADDRESSRESOLUTION_WORKER_PRIVATE_KEYEXCHANGE_SYNC_SECRETRoadmap