Skip to main content

SDK and public API reference

Package: @slip/sdk

AI Rulebook compiler

compileMarketRule(options) calls an AI SDK language model with generateText and Output.object(). Its Zod schema permits only semantic concepts that Slip can map to canonical TxLINE leaves.
OptionTypeBehavior
modelAI SDK model or AI Gateway identifierRequired. The SDK does not silently select a provider.
textstringNatural-language market request. Empty input fails.
fixtureFixtureTrusted fixture ID, teams, competition, and kickoff supplied outside the model.
abortSignalAbortSignalOptional request cancellation.
createOllamaRuleModel({ model, baseURL }) returns an AI SDK LanguageModel for a local or LAN-hosted Ollama server. The default URL is http://127.0.0.1:11434/api; remote MBP setups must pass their server-side LAN URL explicitly. The structured output contains:
  • supported and a nullable rejection reason;
  • one semantic expression kind: team stat, total, home-away difference, or team minimum;
  • one TxLINE concept: goals, yellow cards, red cards, or corners;
  • one documented period;
  • two to five unique outcome labels;
  • two to eight ordered, contiguous integer bands;
  • a human-readable Rulebook sentence.
The model cannot provide raw stat keys, fixture IDs, fees, deadlines, stakes, proofs, or results. compileMarketRuleOutput deterministically maps its semantic output to TxLINE keys and calls validateRule. Unsupported, ambiguous, non-integer, incomplete, or incoherent output throws MarketRuleCompilationError before an instruction can be built. RULEBOOK_PROMPT_SKILLS separates stat selection, expression selection, outcome partitioning, and settlement safety. RULEBOOK_PROMPT_EXAMPLES supplies diverse five-band, BTTS, 1X2, red-card, and unsupported-player demonstrations. buildRulebookSystemPrompt() assembles both for every provider; no example bypasses schema or deterministic validation.

Deterministic construction

These functions do not call a model:
ExportBehavior
statExpressionOne team stat for any supported concept and period.
totalExpressionHome plus away for any supported concept and period.
binaryExpressionCanonical Add, Sub, or Min over the two team leaves.
resultExpressionHome goals minus away goals.
bothTeamsExpressionMinimum of the two team values.
thresholdRuleComplete binary partition for gt, gte, lt, lte, or eq.
resultRuleComplete three-outcome match-result partition.
validateExpressionStat key, side, period, fixture, and operation coherence.
validateRuleExpression plus complete outcome partition.
validateMarketRule, u64 ID, safe timestamps, and fee configuration.
Validation mirrors program constants: five outcomes, eight bands, 48 UTF-8 bytes per label, 500 fee bps, 200 resolver-tip bps, and a 1,000,000-unit minimum stake.

TxLINE client

TxlineClient is browser-safe and uses the real TxLINE HTTP boundary. It owns short-lived guest JWT acquisition, concurrent JWT reuse, one renewal after HTTP 401, API-token headers, timeouts, JSON validation, and precise boundary errors.
MethodBoundary
listFixtures(startEpochDay?)GET /api/fixtures/snapshot
getFixture(fixtureId, referenceEpochSeconds?)Finds one fixture in the applicable live snapshot.
scoreSnapshot(fixtureId)GET /api/scores/snapshot/{fixtureId}
latestSeq(fixtureId)Validated latest sequence from the score snapshot.
proofForMarket(expression, seq?)Stat-validation request plus independent Tier-A verification.
activate(options)Confirmed subscription callback, exact wallet signature, then POST /api/token/activate.
Activation accepts real subscribe() and signMessage() callbacks because wallet and transaction authority remain application-owned. It rejects missing subscriptions, non-64-byte signatures, and invalid activation responses.

Solana client

Instruction builders

SlipClient exposes:
  • createMarketIx
  • buyTicketIx
  • resolveMarketIx
  • claimTicketIx
  • voidMarketIx
These return legacy TransactionInstruction objects at the isolated Anchor compatibility boundary. @slip/sdk/generated contains the Kit-native Codama output.

Executed transactions

The matching high-level methods are createMarket, buyTicket, resolveMarket, claimTicket, and voidMarket. They use executeInstructions to:
  1. obtain a recent blockhash and last-valid block height;
  2. assemble required instructions and compute budget;
  3. request the application-owned authority signature;
  4. simulate with signature verification;
  5. submit without skipping preflight;
  6. confirm using the blockheight strategy;
  7. return signature, simulation compute units, and confirmation slot.
keypairAuthority adapts a server-side Keypair. Browser wallets can implement TransactionAuthority or continue using the instruction builders with Wallet Standard tooling. Buy, resolve, and claim prepend idempotent SPL-token ATA creation for required user, resolver, treasury, and refund destinations.

Accounts

  • getMarket, getTicket, listMarkets, listTickets
  • listMarketsPage, listTicketsPage
  • watchMarkets, watchTickets
  • marketAddress, ticketAddress, rootsPda
Page cursors are ordered account public keys. Solana core RPC still performs one getProgramAccounts scan because it provides no server-side limit or cursor. The SDK states this explicitly; production indexing requires a real Geyser or indexed RPC boundary.

Money helpers

ExportReturn
settlementInteger total, fee, tip, and net.
marketOddsProbability bps and decimal-odds strings for each outcome.
projectedPayoutFloored payout, or null for zero winning liquidity.
validateStakeu64 range and one-USDT minimum validation.
All token arithmetic uses bigint. No floating-point token calculation enters the SDK.

Public HTTP API

All routes are uncached and CORS-readable. Live-boundary failures do not return sample data.
RouteResponse
POST /api/v1/compileAI-compiled, schema-validated Rulebook for a live TxLINE fixture.
GET /api/healthzSolana program and TxLINE health.
GET /api/v1Deployment and Rulebook-compiler capabilities.
GET /api/v1/openapi.jsonOpenAPI 3.1 document.
GET /api/v1/fixturesFuture TxLINE fixtures.
GET /api/v1/marketsUnified Solana markets with fixture metadata and tickets.
GET /api/v1/markets/{address}One market by Solana address.
The compile route returns 422 when language cannot become a supported market and 503 when AI or TxLINE configuration is unavailable. Market creation controls remain absent when either the unified program or the server-side compiler is unavailable.