Docs

Technical Documentation

Architecture, integration guides, and API reference for ProofPlay Markets

Overview

ProofPlay Markets is a verifiable prediction market dApp for World Cup matches. Users create rooms, pick a side, stake SOL, and earn payouts when the match ends — all verified through TxLINE's real-time sports data oracle with settlement receipts anchored on Solana Devnet.

Market Types
Winner Pick + Goal Rush
Settlement
TxLINE Merkle Proofs
Network
Solana Devnet
Architecture

The system uses Next.js 15 API routes as the backend, with an Anchor program on Solana for on-chain market state. TxLINE provides real-time match data and Merkle-verified results.

User (Frontend)
Next.js API Routes
Anchor Program
TxLINE Oracle
Frontend
  • Next.js 15 App Router (React 19)
  • Privy wallet auth (Solana)
  • Tailwind CSS v4, glass UI
  • Phantom wallet integration
Backend
  • Next.js API routes (serverless)
  • Vercel KV for room persistence
  • Anchor + @coral-xyz/anchor SDK
  • TxLINE REST + SSE client
Smart Contract

The Anchor program manages prediction markets on-chain. Each fixture has one market PDA. Participants join via a derived participant PDA.

// Program IDD254EggCVsZ7jKtJJ29diEv3P4qqjn5APBAvcRwDNsyE// Market PDA seeds[b"market", creator, fixtureId_le]// Participant PDA seeds[b"participant", market, wallet]
Instructions
  • initializeMarket — Create a new market PDA
  • joinMarket — Join with stake, creates participant PDA
  • lockMarket — Lock before kickoff
  • settleMarket — Settle with winner + merkle root
  • claimPayout — Winner claims SOL from pool
Accounts
  • Market — Fixture ID, market type, threshold, status, participants, total stake
  • Participant — Wallet, side, amount, claimed flag
API Reference

All room management is handled through Next.js API routes under /api/rooms.

RouteMethodDescription
/api/roomsPOSTCreate a new prediction room
/api/roomsGETList all rooms
/api/rooms/[id]GETGet room details
/api/rooms/[id]/joinPOSTJoin a room
/api/rooms/[id]/lockPOSTLock room at kickoff
/api/rooms/[id]/settlePOSTSettle with TxLINE proof
/api/rooms/[id]/claimPOSTBuild claim transaction
/api/rooms/[id]/claim/submitPOSTSubmit payout
/api/rooms/[id]/receiptGETGet settlement receipt
/api/txline/fixturesGETList all fixtures
/api/txline/scores/[id]GETGet score snapshot
/api/txline/streamGETSSE score stream
TxLINE Integration

TxLINE is the real-time sports data oracle. All match data — scores, status, stats — flows through TxLINE's API with Merkle-tree based verification for on-chain settlement.

Auth
JWT in Authorization: Bearer
API token in X-Api-Token
Expires after 30 days
Status Mapping
StatusId 5/7/9 → finished (full time / extra time / penalties)
StatusId 2/3/4 → in_progress
StatusId 1 → scheduled
Score Snapshot Response
[
  {
    "FixtureId": 123,
    "Seq": 42,
    "StatusId": 5,
    "Score": {
      "Participant1": { "Total": { "Goals": 2 } },
      "Participant2": { "Total": { "Goals": 1 } }
    },
    "Clock": { "Seconds": 5580 }
  }
]
Settlement Flow

Settlement is triggered by the room creator after the match ends. The system fetches the final score from TxLINE, validates it with a Merkle proof, and records the result.

1
Fetch Score

GET /api/scores/snapshot/{fixtureId} — retrieves the latest score event with StatusId 5/7/9 (finished)

2
Determine Winner

Goal Rush: total goals vs threshold | Winner Pick: HOME/AWAY/DRAW based on scores

3
Stat Validation

POST /api/scores/stat-validation — requests a Merkle proof for the winning stat

4
On-Chain Settle

Calls settleMarket on the Anchor program with the winner side + merkle root

5
Generate Receipt

Stores the full settlement receipt: score, validation, merkle root, payout summary

6
Claim Payout

Winner signs a claim transaction → server sends SOL from the pool to their wallet

Quick Start

Run the project locally to explore the full flow.

# 1. Clone and installgit clone https://github.com/Saber1Y/ProofPlayMarkets cd ProofPlayMarkets npm install --legacy-peer-deps# 2. Set up environmentcp .env.example .env# Add TXLINE_JWT, TXLINE_API_TOKEN, NEXT_PUBLIC_PRIVY_APP_ID# 3. Run locally (SSL workaround for expired devnet cert)NODE_TLS_REJECT_UNAUTHORIZED=0 npm run dev# 4. Open http://localhost:3000
Prerequisites
  • • Node.js 18+
  • • Phantom wallet (Solana devnet)
  • • Devnet SOL from faucet.solana.com
  • • TxLINE API credentials