LOPWDocumentation

Docs / Guides

Run the scenarios yourself

The demo agent is a short script on top of the buyer SDK. Point it at a reference service, choose a fault, and it prints each step with a transaction hash of its own. A scheduled catalogue runs the same scenarios on a timer and records every run for the demo and proofs pages.

The demo agent

Terminal
AGENT_SECRET=S... SERVICE_URL=https://fx.example.com FAULT=BAD_PRICE pnpm --filter @lopw/demo-agent start

# optional
RESOURCE=/v1/ledger/latest     # another paid endpoint (default /v1/quote?pair=EUR-USD)
REQUIRE=3,4,5                  # predicate IDs the agent insists on (default 6)
RECEIPT_STORE=./receipts.json  # where receipts are kept until their claim windows close

AGENT_SECRET is the agent’s Stellar secret key; the account needs USDC on the same network as the contracts (LOPW_NETWORK, default testnet). The agent reads the service’s bond, pays $0.01 through x402 with the policy minStake: 100 USDC, requiredPredicates: REQUIRE, minMaxClaim: 1 USDC, verifies the receipt and claims if a predicate is breached.

FAULT is sent as the x-lopw-fault request header. A reference service honours it only when its operator has enabled per-request fault injection; otherwise its own configured mode applies.

Fault modeWhat the seller doesExpected result
NORMALServes correctlyReceipt verified; warranty kept; no claim
BAD_PRICEQuotes 10% below the oracle, citing the real observationP6 claim paid (FX service)
STALE_DATAServes data an hour old with an honest data_as_ofP3 claim paid
WRONG_TERMSSigns the receipt with a different terms_hashP2 claim paid
DUPLICATE_RECEIPTSigns a second receipt with a different response_hash for the same paymentP1 claim paid
BAD_STATUSCharges for HTTP 203 when only 200 is allowedP4 claim paid (ledger service)
OVERSIZEReturns more than the 4 KiB promisedP5 claim paid (ledger service)
BAD_SIGNATURESends a receipt with a broken signatureSDK flags the response untrusted; no claim; no penalty

The reference services

ServiceWhat it sellsWarranty
FX quote APIEUR/USD quoted against USD, $0.01 per callP1, P2, P3 (600 s), P4 ([200]), P6 (EUR on the fiat-rates oracle, 50 bps, 600 s); claim window 1 h
Ledger data APILatest-ledger facts and account balancesP1, P2, P3 (30 s), P4 ([200]), P5 (4096 bytes); claim window 1 h

The scheduled catalogue

Eleven named scenarios run against the live reference services with real x402 payments, on a schedule (every six hours by default), and every run is judged against the scenario’s expected outcome and recorded with its payment and claim transactions, payout and stake before and after. Payouts are recycled into the seller’s stake so the services stay funded.

ScenarioExpected
Honest FX quoteReceipt verified; warranty kept; no claim; stake unchanged
Quote 10% off the oracleP6 claim paid 5 USDC
Data older than promisedP3 claim paid 5 USDC
Receipt cites different termsP2 claim paid 5 USDC
Two different receipts for one paymentP1 claim paid 5 USDC
Broken receipt signatureUntrusted; no claim; no penalty
Charged for an unpromised statusP4 claim paid 1 USDC
Response larger than promisedP5 claim paid 1 USDC
Same claim filed twiceSecond submission fails with AlreadyClaimed
Claim against an honest receiptRejected as NotProven; no payout
Agent policy refuses an under-staked sellerPayment refused by policy; no transaction
HTTP
GET /v1/testnet/scenarios?runs=5
// [ { "id": "bad-price", "title": "…", "summary": "…", "why": "…", "steps": [ … ], "expected": "…", "service": "fx",
//     "totals": { "runs": 12, "passed": 12 },
//     "runs": [ { "id": 1, "started_at": …, "finished_at": …, "outcome": "pass", "observed": "…", "payment_tx": "…", "claim_tx": "…", "payout": "50000000", "stake_before": "…", "stake_after": "…", "service_id": "…" } ] } ]

The demo and proofs pages are built from this feed. What each scenario demonstrates and why it matters is in Proofs and scenarios.