Start > Build your first market
Build your first market
Explain the full market lifecycle from creation to claim.
Build your first market
This tutorial explains how a Quovra market works from creation to payout.
You will create a mental model for four instructions:
create_marketdepositsettleclaim
Lifecycle
mermaid
stateDiagram-v2
[*] --> Created
Created --> Funded: deposit YES/NO
Funded --> Closed: close_ts reached
Closed --> Resolved: settle(TxLINE proof)
Resolved --> Claimed: winner claim()
Closed --> Closed: invalid proof reverts1. Define the market
A market stores the terms needed to verify a future proof:
| Field | Example | Purpose |
|---|---|---|
market_id | 250701 | Stable market identifier |
fixture_id | 18250701 | TxLINE fixture id |
stat_key | 1 | Stat to prove |
threshold | 0 | Predicate threshold |
close_ts | kickoff timestamp | Deposit cutoff |
question | "Will Spain score in the final?" | Public market copy |
Quovra rebuilds the predicate from stored terms during settlement. A caller cannot submit different terms later.
2. Create the market
The create_market instruction initializes:
MarketPDA- vault authority PDA
- SPL token vault
- stored fixture/stat terms
TypeScript example:
ts
await program.methods
.createMarket(new BN(250701), new BN(18250701), 1, 0, new BN(closeTs), "Will Spain score in the final?")
.accounts({
authority,
market,
mint,
vaultAuthority,
vault,
tokenProgram: TOKEN_PROGRAM_ID,
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
systemProgram: SystemProgram.programId,
})
.rpc()Expected result:
- The market account exists.
- The vault token account exists.
resolved = false.
3. Deposit
Users deposit devnet USDC on YES or NO.
ts
await deposit(connection, wallet, marketPubkey, 1, 10)Expected result:
- 10 devnet USDC moves to the vault.
- The user's
PositionPDA records outcome1. - Additional deposits must use the same outcome.
4. Settle
After the fixture ends, a keeper submits the TxLINE stat-validation payload.
bash
cd app
SOLANA_KEYPAIR=~/.config/solana/quovra-dev.json npm run keeper:settle -- --executeExpected result:
- Quovra CPIs into
txoracle.validate_stat. - A valid proof returns a boolean.
- The market stores
yes_won. - Invalid proof transactions revert.
5. Claim
Winning wallets claim with a separate pull-payment transaction.
ts
const signature = await claim(connection, wallet, marketPubkey)Expected result:
- The winner receives stake plus pro-rata losing-pool share.
position.claimed = true.- Repeated claims fail with
AlreadyClaimed.
Related pages
Search keywords
create_market, deposit, settle, claim, lifecycle, prediction market
Last updated: [YYYY-MM-DD]