withSettleDedupe, which serves each settled payment once. This page
uses the hosted testnet facilitator.
Requires Node.js 24, which runs the
.ts file below directly. The upstream x402 e2e suite also passes
through Rail402 with the stock Hono, Fastify and Next.js servers; see Conformance
evidence.1. Install
2. A receiving account
payTo must be able to hold the asset. For a G… account that means a USDC trustline. Without one,
payments to it are refused with invalid_exact_stellar_payload_recipient_trustline_missing. The
create-account.ts script from the buyer quickstart
creates a testnet account with the trustline:
3. The seller
seller.ts
price: "$0.01"is converted by the stock Stellar server scheme into Circle testnet USDC:amount: "100000"(7 decimals) of contractCBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA.x402ResourceServerreads/supportedfrom the facilitator, so the payment requirements carryextra: { areFeesSponsored: true }.withSettleDedupeserves each settled payment once. Rail402 answers every/settleof the same payment with its success, and copies of a payment sent at the same time all pass/verifybefore the first one settles; the wrapper refuses the copies withseller_settlement_repeat. See Serve each payment once.bazaarResourceServerExtensionanddeclareDiscoveryExtensionpublish the route’s discovery metadata: the query parameters it takes, their JSON Schema, and an example output.
402 with a PAYMENT-REQUIRED header. Decoded, it looks like this (illustrative and
abridged; payTo is your account):
4. Get listed
When a payment that carries the bazaar extension settles, Rail402 catalogs the resource and tells the seller the outcome in theEXTENSION-RESPONSES header of its /verify and /settle responses. The stock
HTTPFacilitatorClient logs both:
awaiting_origin_verification: Rail402 then requests the
resource without payment, and lists it once the 402 your server answers with confirms the payment options
and metadata. Later settlements report recorded, or awaiting_origin_verification when the payment carries
changed metadata. The full outcome also carries
listingId and version; see Cataloging.
Once listed, the resource appears in discovery, bound to your payTo:
402 it gets
back names the same payTo and a matching bazaar extension, the listing’s trust becomes
origin_verified and a new version is recorded.
To have your domain vouch for the listing as well, bind the domain and the account both ways (SEP-1). Publish a
stellar.toml at https://<your host>/.well-known/stellar.toml that lists your payTo account:
payTo account’s home domain (a setOptions operation with homeDomain, for
example stellar tx new set-options --home-domain <your host> with the Stellar CLI). Within minutes the
listing’s trust becomes domain_verified.
Changing price or metadata
Change the route config and redeploy. The next settlement reports the change as proposed (awaiting_origin_verification); Rail402 then requests the resource and publishes what its own 402
response declares. Every published change is a new entry in the listing’s
public version history. A different payTo settling for the same
resource cannot take the listing over unless the resource’s own 402 names that payTo.