What openx402 provides
openx402 is a self-hostable x402 v2 facilitator for Stellar. It verifies and settles payments, sponsors Stellar transaction fees, records Bazaar metadata, and exposes HTTP and MCP discovery. This tutorial uses the hosted public testnet services:
You will run the included Rock Paper Scissors seller and canonical paying
client locally. The hosted MCP does not hold a buyer key and cannot pay.
Prerequisites
- Node.js 22 or newer
- npm
- a Stellar testnet buyer secret key (
S...) for an account holding testnet XLM - a Stellar testnet seller address (
G...) - an HTTPS tunnel that forwards a public origin to
http://127.0.0.1:4788 curlandjqfor the catalog check
Why the seller needs a public HTTPS URL
The payment challenge and Bazaar metadata must describe the URL the buyer actually calls. SetSELLER_PUBLIC_URL to the tunnel origin, not the local
listener.
The hosted catalog rejects loopback/private origins and plain-HTTP public
resources. A value such as http://127.0.0.1:4788 is valid for local-only
testing but cannot become a hosted listing.
1
Install the example
From the repository root:
2
Start the seller
Start your HTTPS tunnel first and forward it to port The process listens on
4788. Then, from
examples/rock-paper-scissors:127.0.0.1:4788 and prints its local URL, public URL,
facilitator, seller address, asset contract, and atomic amount. Leave it
running.The addresses have distinct roles:SELLER_PAY_TOreceives the payment asset.- the buyer address owns and authorizes the payment asset.
- the facilitator sponsor address pays the Stellar network fee only.
- the token contract address identifies the payment asset.
3
Run the paying client
Open another terminal in The output is JSON with three sections:
examples/rock-paper-scissors:paymentRequired: selected scheme, network, asset, amount, recipient, resource, and Bazaar declaration;settlement: the canonicalPaymentSettleResponse, including a real testnet transaction hash;result: the player move, random server move, and result.
PaymentRequired, creates and signs a Stellar exact payment, encodes the
payment headers, and retries the same application request. The seller asks the
facilitator to verify and settle. The facilitator pays the network fee while
the buyer supplies the payment asset. The successful response includes the game
result and a settlement response containing the testnet transaction hash.4
Confirm automatic cataloging
From any directory:Look for the public tunnel URL and the
Rock Paper Scissors service name.Cataloging is a configured side effect, not an unconditional result of every
402 response. The hosted facilitator uses index_on: verified: valid Bazaar
metadata becomes catalogable after a successful configured payment
observation. Invalid metadata soft-fails without invalidating an otherwise
valid payment. A listing records payment_observed; it does not prove origin
ownership or service quality.