BharatMarket

Protocol docs

NetworkPolygon Amoy
CollateralUSDC
StageTestnet beta
SourcePublic GitHub

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.

Concepts

BharatMarket 101

1Connect a Polygon Amoy wallet and fund it with USDC plus enough POL for gas.
2Create or open a market. Every live production market should carry structured oracle metadata.
3Trade YES or NO shares, add liquidity, and monitor probabilities from the indexed backend.
4After expiry, the resolution worker requests Chainlink Functions to fetch provider data.
5Once the market resolves on-chain, the indexer syncs outcome state and redemption unlocks.

Market types

Supported markets

Crypto markets

Live

CoinGecko-backed price_above and price_below markets for BTC, ETH, SOL, and USDC-style outcomes.

Cricket markets

Live

CricAPI-backed winner markets using finished fixture data and deterministic team normalization.

Election markets

Planned

Visible as architecture only until verified, reproducible election result providers are added.

Lifecycle

Market lifecycle

01

Create Market

02

Trade YES / NO

03

Market Expires

04

Oracle Verification

05

On-chain Settlement

06

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 redemption

Using 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

1Use the public API to read indexed market state.
2Use the SDK foundation for create, buy, liquidity, portfolio, and redeem flows.
3Subscribe webhooks for market and oracle lifecycle events.
4Use embeds for partner surfaces that need a compact board or market card.

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/oracles

Webhooks

Event model

market.createdtrade.executedliquidity.addedoracle.requestedoracle.completedmarket.resolved

Reference

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_SECRET

Roadmap

Current stage and next plans

Live / built

Done
Crypto creation, trading, indexing, Chainlink Functions settlement, and redemption
Cricket winner-market creation and provider-backed settlement path
Backend indexer with market, activity, portfolio, snapshot, and oracle state
Autonomous resolution worker and Vercel-compatible sync endpoints
Public API, webhook foundation, SDK foundation, and embed widgets

Planned next

Next
Multi-outcome markets
Creator revenue sharing
Trader and creator reputation
Private markets and access control
API keys and developer tiers
Verified election settlement
Mainnet-ready deployment hardening