Docs / Guides
Add a warranty to an x402 API
Turn an existing x402 endpoint into a bonded one. Six steps; the detailed code is in Getting started for sellers.
- Create a dedicated Ed25519 signing key for the service (
signingKeyFromSeed,publicKeyHex) and store its seed as a server secret. - Pick the predicates you can honour and set their limits (guide). Every parameter is part of the hashed terms.
- Register the service:
binding.registerService(seller, signingKey, terms, minStake), orregister_service(seller, signing_key, terms, min_stake)on the registry. Keep the returnedservice_id. - Deposit at least 100 USDC:
binding.deposit(seller, serviceId, amount). When stake reachesmin_stakethe service turnsActive. - Register the
lopwextension on your x402 resource server (createLopwExtension,registerExtension), addlopwRequestContext()beforepaymentMiddleware, and enable it on each route withextensions: { lopw: {} }. - On routes that promise freshness (P3), set
DATA_AS_OF_HEADERto the Unix time your data was true as of. On routes that promise P6, setORACLE_EVIDENCE_HEADER.
TypeScript
const lopw = createLopwExtension({ binding: new StellarBinding(network), serviceId, signingSeed, maxClaim: 5n * 10_000_000n });
const server = new x402ResourceServer(new HTTPFacilitatorClient({ url: facilitatorUrl }))
.register(network.caip2, new ExactStellarScheme())
.registerExtension(lopw);
app.use(lopwRequestContext());
app.use(paymentMiddleware({ "GET /v1/quote": { accepts: [{ scheme: "exact", price: "$0.01", network: network.caip2, payTo, maxTimeoutSeconds: 60 }], extensions: { lopw: {} } } }, server));The middleware only issues offers while the service is Active. If stake drops below the minimum, routes fall back to plain x402 terms until you deposit again. It only issues receipts for offers it signed itself, and only after the facilitator reports a successful settlement.
Check your work
GETyour route without payment: the 402 body’sextensions.lopw.infocarriesversion,network,registry,service_idand a base64offer.- Pay it with the buyer SDK:
warranty.problemsis empty andwarranty.breachesis empty. - Read the service over the public API: state
Active, stake as expected.