Prerequisites
- Node.js 22+ (or an equivalent runtime with the
@stellarx402/clientSDK) - A Stellar wallet keypair funded with Testnet USDC (faucet)
- The facilitator URL (
https://facilitator.stellarx402.comfor the hosted version)
1. Install the client SDK
2. Search the Bazaar
3. Pay for the resource
fetchWithPayment handles the 402 challenge, builds and signs the payment, retries with the X-Payment header, and returns the resource response.
4. Handle a rejection
Not every payment will succeed, and the difference between “you are out of budget” and “that endpoint no longer exists” matters when nobody is watching your agent. Every rejection has a stable machine-readable code:Where to go next
Searching the Bazaar
Filters, ranking, and pagination for the discovery API.
Handling Rejections
Every machine-readable reason a payment can fail, and how an agent should react to each one.
Budgets & the Upto Scheme
Cap what an agent can spend across a session or per-tool, using smart account contracts.
MCP Integration for Agents
Wire the Bazaar and the payment client into an MCP-speaking agent runtime.