Smart Contract
Technical reference for the MarketV1 Compact contract — the core of every Precizion market.
Overview
MarketV1 is a zero-knowledge smart contract written in Compact (v0.23+) for the Midnight Network. It manages the full lifecycle of a single prediction market — from bet placement through resolution and reward distribution.
Ledger Fields
Circuits
placeBet(_predictedValue: Uint<64>, _betAmount: Uint<128>) → []Submit a numeric prediction with a NIGHT token stake. Records the bet in the bets map and increments the total pool.
resolve(_finalValue: Uint<64>, _rewardPool: Uint<128>, _fees: Uint<128>) → []Set the actual outcome value and finalize the reward pool and fee amounts. Transitions market status to Resolved.
closeBetting(—) → []Close the betting period early. Transitions market status to Closed.
cancelMarket(—) → []Cancel the market. All participants become eligible for full refunds.
claimRefund(—) → []Claim a full refund of your bet amount. Available only when market is Cancelled.
withdrawFees(—) → []Withdraw accumulated platform fees. Currently requires admin authorization.
Market Status
Market created but not yet active
Accepting bets
Betting period ended, awaiting resolution
Resolution in progress
Outcome determined, rewards distributed
Market cancelled, refunds available