Truvian Shield Docs

Build

HTTP API.

Every desk is one POST; every decision is a signed memo you can fetch and verify; no API key is needed. The first 5 runs a day per IP address are free; after that a run costs $0.05 in test USDC over x402.

Routes

Method and pathWhat it does
POST /api/preflightruns a desk: mode is trade, listing, holdings or settlement
POST /api/resolveresolves a prediction market
GET /api/memo/:ida stored desk memo with its sha256, message, signature and signer
GET /api/memos?limit=nthe latest desk decisions (up to 50) and the signer
GET /api/resolution/:id, GET /api/resolutionsa stored resolution with its Solana anchor; the latest resolutions (?current=1 keeps only the latest run of each market)
POST /api/memo/verify{memo, signature}: recomputes the digest and recovers the signer; free
GET /api/signal/:hashlooks up a Telegraph signal hash on the node
GET /api/statslive counters, the free allowance left for you, the price, and the node's ledger for Shield's escrow
POST /api/check, GET /api/report/:id, GET /api/recent, GET /api/verify/:txHashthe Season I pre-sign check behind /app
GET /healthz{ok: true}

Examples

# a trading agent: may I buy $1,000 of WETH through the Uniswap V3 USDC/WETH pool?
curl -s https://truvian.xyz/api/preflight -H 'content-type: application/json' -d '{
  "mode": "trade", "chain": "ethereum",
  "token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
  "pool":  "0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640",
  "tradeUsd": 1000
}' | jq '{decision: .memo.decision, rule: .memo.decisionRule, cost: .memo.cost, url}'

# a custodian: may I pay 1 rUSD to this counterparty on Solana devnet?
curl -s https://truvian.xyz/api/preflight -H 'content-type: application/json' -d '{
  "mode": "settlement", "network": "solana-devnet", "mint": "RUSD", "amount": "1",
  "recipient": "Afb8MYs9G63oHAPkZiK6cb5JKzuWy9is3pHc6Zj5voYZ",
  "counterparty": "Coinbase Global, Inc.", "jurisdiction": "US-DE", "execute": true
}' | jq '{decision: .memo.decision, sent: .memo.settlement.execution.reason}'

# a market: what really happened?
curl -s https://truvian.xyz/api/resolve -H 'content-type: application/json' \
  -d '{"source": "polymarket", "market": "253591"}' | jq '{decision: .memo.decision, outcome: .memo.outcome, anchor}'

A successful run answers {type: "memo", id, memo, sha256, message, signature, signer, url}. Invalid input is 400 INVALID_INPUT with a message; a chain that does not answer is 503 and nothing is bought.

Streaming

Add ?stream=1 (or accept: application/x-ndjson) to watch a decision assemble as newline-delimited JSON:

EventCarries
startthe normalized input
chain / holdings / solanaShield's own reads: token facts, each holding, or the Solana mint, its restrictions and the payer's balance
marketresolution only: the market as its venue states it
planthe facts to buy and the escrow balance
purchase / answerone per answer, with miner, cost, latency, receipt and signal
executionsettlement only: whether the payment was sent, and its read-back
memothe signed memo
paymenton a paid run: whether your payment settled, and its transaction
doneyour free runs left today

Paying with x402

Past the free runs, a desk answers 402 with a price instead of running:

{"x402Version": 1,
 "error": "... Pay $0.05 in USDC to run this check now.",
 "accepts": [{"scheme": "exact", "network": "base-sepolia", "maxAmountRequired": "50000",
   "payTo": "0xCd0a2370F2dC12c1802707B7d9aB3fec891E3c02",
   "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", "maxTimeoutSeconds": 300,
   "extra": {"name": "USDC", "version": "2"}}]}

Sign an EIP-3009 TransferWithAuthorization for that amount and send the same request again with X-PAYMENT: base64({x402Version, scheme, network, payload: {signature, authorization}}). Shield verifies it with the facilitator before running and settles it only after the run succeeds; the caller pays no gas. On the website this is automatic: pay.js shows the price and wallet.js asks the visitor's browser wallet for the signature. A malformed header counts as no payment; a well-formed one with a bad signature is refused with 402 and nothing runs.

Verifying a memo

A memo's digest is SHA-256 over its canonical JSON (keys sorted, no spaces; canonicalJson in src/shield/memo.ts). The signed message is Truvian Shield memo sha256:<digest> under EIP-191. POST /api/memo/verify answers {sha256, message, recoveredSigner, signedByThisShield, shieldSigner}; any EIP-191 library recovers the same signer offline. Change one field and it fails.

Limits