Builder Quickstart (AI-friendly)
TL;DR: end-to-end path: connect → init config → create/verify market creator → create market → open position → resolve (manual/Switchboard) → payout → reclaim LUT rent. Program ID (devnet/mainnet): deprZ6k7MU6w3REU6hJ2yCfnkbDvzUZaKE4Z4BuZBhU.
Environment facts (copyable)
{
"programId": "deprZ6k7MU6w3REU6hJ2yCfnkbDvzUZaKE4Z4BuZBhU",
"rpc": "https://api.devnet.solana.com",
"das": "<your-das-endpoint>",
"defaultMint": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
"tokenPrograms": ["SPL Token", "Token-2022 (auto-detected)"],
"questionMaxLen": 80
}Action cards
1) Initialize client
- Action: create SDK instance (connection only)
- Inputs:
connection - Outputs:
client
import { Connection } from '@solana/web3.js';
import DepredictClient from '@endcorp/depredict';
const connection = new Connection('https://api.devnet.solana.com');
const client = new DepredictClient(connection);2) Initialize protocol config (one-time)
- When: first setup
- Inputs:
feeAmountBps,feeVault,payer - Outputs:
ixs(submit with payer)
const feeVault = new PublicKey('...'); // ATA for chosen mint
const payer = new PublicKey('...'); // authority
const ixs = await client.config.createConfig(50, payer, feeVault);
// sendTx(ixs, [payerSigner])3) Create & verify market creator (one-time per platform)
- Inputs:
name,feeVault,creatorFeeBps (<=200),signer,coreCollection?,merkleTree? - Outputs:
{ ixs, marketCreator }
const { ixs, marketCreator } = await client.marketCreator.createMarketCreator({
name: 'My Platform',
feeVault,
creatorFeeBps: 50, // 0.5%
signer: payer,
});
// sendTx(ixs, [payerSigner])
await client.marketCreator.verifyMarketCreator({
signer: payer,
coreCollection: new PublicKey('...'),
merkleTree: new PublicKey('...'),
});4) Create market
- Inputs:
startTime,endTime,question<=80,metadataUri,payer,oracleType,marketType,bettingStartTime?,mintAddress? - Outputs:
{ tx, marketId }
const { tx, marketId } = await client.trade.createMarket({
startTime: Math.floor(Date.now()/1000),
endTime: Math.floor(Date.now()/1000) + 86400,
question: 'Will SOL close above $200 today?',
metadataUri: 'https://example.com/market.json',
payer,
oracleType: OracleType.MANUAL, // or OracleType.SWITCHBOARD
marketType: MarketType.LIVE, // FUTURE requires bettingStartTime
mintAddress: TOKEN_MINTS.USDC_DEVNET, // optional; defaults to USDC devnet
});
// send tx with payer signer5) Open position
- Inputs:
marketId,amount(human units, auto-scaled by mint decimals),direction,metadataUri,payer - Outputs:
{ ixs, addressLookupTableAccounts, nftMint }
const { ixs } = await client.trade.openPosition({
marketId,
amount: 25, // 25 USDC, auto *10^decimals
direction: { yes: {} }, // or { no: {} }
payer,
metadataUri: 'https://example.com/position.json',
});
// sendTx(ixs, [payerSigner])6) Resolve market
- Manual:
await client.trade.resolveMarket({ marketId, payer, resolutionValue: 10 /* YES */ }) - Switchboard: store
oraclePubkeyat creation; callresolveMarket({ marketId, payer })
7) Payout (settle)
- Inputs:
marketId,payer,assetId(compressed NFT),rpcEndpoint,returnMode? - Outputs:
{ ixs | message | transaction, alts[] }
const res = await client.trade.payoutPosition({
marketId,
payer, // claimer
assetId: new PublicKey('...'),
rpcEndpoint: '<your-das-endpoint>',
returnMode: 'transaction',
});
// submit res.transaction with payer signer (include ALTs)8) Close market & reclaim LUT rent
- Close market:
await client.trade.closeMarket(marketId, payer); - LUT rent: use
ensureMarketCreatorLookupTable/ensureMarketLookupTablethenbuild...CloseTxsto reclaim deposits after payouts.
Metadata schemas (templates)
Market JSON (example){
"name": "SOL > $200?",
"description": "Will SOL close above $200 today?",
"external_url": "https://example.com",
"image": "https://example.com/image.png",
"tags": ["solana", "price", "daily"]
}{
"name": "YES on SOL > $200",
"description": "YES position for market 123",
"image": "https://example.com/yes.png",
"attributes": [
{ "trait_type": "direction", "value": "yes" },
{ "trait_type": "marketId", "value": 123 }
]
}Validation & guardrails
- Question max length: 80 chars.
- FUTURE markets must set
bettingStartTime <= startTime. - Token program auto-detected (SPL Token or Token-2022); ensure ATAs match the mint’s program.
- Resolution: manual requires
resolutionValue; Switchboard requiresoraclePubkeyset at creation. - Payout requires DAS/MAS endpoint for compressed NFT proofs.
Suggested agent flow (for automation)
- Load environment constants.
- If no config: call
createConfig. - If no market creator:
createMarketCreator→verifyMarketCreator. createMarket(storemarketId).openPositionfor user.resolveMarket.payoutPositionwith proof RPC.closeMarketand close LUTs to reclaim rent.
