Bazaarx402 discovery for Stellar, live on mainnet and testnet

The paid web, searchable.

Every API and MCP tool paid through Rail402 lands in the Bazaar. Agents find what they need in plain words and pay per call on Stellar, without an account anywhere.

Standard x402Stock packages. No lock-in.
Tested upstreamPasses the official x402 suite.
0 XLM feesRail402 pays the network fee.
Open sourceApache-2.0. Self-host or use ours.
01The problem

APIs make you sign up before you can ask.

An API is a service your code can ask for something: the weather, a translation, a picture. Most want an account, a credit card and a secret key first. For an AI agent that needs one answer right now, that doesn't work.

With Rail402 the API just names its price, and your code pays for that one answer.

Today

Create an account
Confirm your email
Add a credit card
Keep an API key secret
Pay a monthly bill

With Rail402

GET/weather?city=Istanbul
402price 0.001 USDC
PAYone signature
20021°, sunny
02How it works

Ask, pay, get the answer. In one round trip.

The web has had a "402 Payment Required" code since 1997 that nobody could use. x402 is the open standard that does. Rail402 is the facilitator in the middle: it checks the payment, sends it to Stellar and pays the fee.

  • The buyer signs once. Change the amount or the receiver and the signature breaks.
  • The money goes straight from buyer to seller. Rail402 never holds it.
  • Every refusal comes back with a clear code and a reason.
How the facilitator works →
200{ "city": "Istanbul", "temperature": 21, "conditions": "sunny" }
03Built on Stellar

Money that moves as fast as the request.

Paying a tenth of a cent only makes sense if the payment is fast and almost free. On Stellar it's final in about five seconds, in USDC, a digital dollar, and the network fee is a tiny fraction of a cent that Rail402 pays for you.

Networks and assets →
≈ 5 suntil final
USDC1 USDC = 1 USD
≈ 0.002 XLMfee, paid for you
04Stellar-native

Made for Stellar, not ported to it.

A payment is a Soroban token transfer. The buyer signs one authorization that names the token, the receiver and the amount, and nothing else can be changed without breaking it. Rail402 puts it on the ledger from its own accounts and pays the fee.

  • Classic G… wallets and C… smart accounts both pay. A smart account runs its own checks.
  • Circle USDC by default, or any SEP-41 token, with 6, 7 or 18 decimals.
  • A pool of channel accounts settles many payments side by side.
Where Rail402 sits on Stellar →
authorization · transfer(from, to, amount)stellar:pubnet
tokenUSDC · Stellar Asset Contract✓
fromthe buyer's wallet✓
toGBSV…ELYP · the seller✓
amount10000 base units = 0.001 USDC✓
signaturebuyer's key · locks all four✓
Rail402 adds only the fee. Change one field and Stellar rejects it.
Sorobanthe upto contract: no admin, cannot be changed
CAIP-2stellar:pubnet and stellar:testnet
@x402/stellarthe official scheme, unmodified
05Pricing models

Two ways to charge.

Use exact when you know the price up front. Use upto when you only know it after the work is done.

exact

Like a price tag

One request, one fixed price. The buyer pays exactly that, and gets the answer.

e.g. a weather report, a translation
upto

Like a taxi meter

The buyer agrees to a maximum. The seller charges what was used. A contract on Stellar makes going over impossible.

e.g. AI tokens, rows of data, seconds of compute
06Built by Rail402

We wrote upto for Stellar.

x402 started with fixed prices. Rail402 wrote the Stellar version of upto, the metered scheme: the specification, the Soroban contract that enforces it, and the code for buyers, sellers and facilitators. It is proposed to the x402 project upstream.

  • The buyer signs a cap and a deadline. The contract checks the amount is between zero and the cap.
  • Each signature settles once and expires with the payment window. The unused part never leaves the wallet.
  • The contract has no admin, can't be changed and stores nothing. Its source is verified on chain.
upto termsupto
cap0.0100 USDC
toGBSV…ELYP
tokenUSDC
expireswith the payment window
✍ signed by the buyer · once
SETTLE0.0042 used · 0 ≤ 0.0042 ≤ 0.0100 ✓
KEPT0.0058 never left the buyer's wallet
REPLAYsame signature again → refused, nothing moved

testnet contract CBTVKCHL…TU7U · source verified

07Sell your API

Charge for your API with one middleware.

Keep your server as it is. Add the stock @x402/express middleware, point it at Rail402 and name a price in dollars. Each call is paid in USDC, straight to your Stellar address.

  • No accounts or billing to build. A request without payment gets a 402.
  • Describe the route once and the Bazaar lists it after the first sale.
  • MCP tools too: charge per tool call with the stock @x402/mcp.
Seller quickstart →
  seller.ts
const facilitator = new HTTPFacilitatorClient({
  url: "https://testnet.rail402.dev" });const server = new x402ResourceServer(facilitator)
  .register("stellar:testnet", new ExactStellarScheme())  .registerExtension(bazaarResourceServerExtension);
app.use(paymentMiddleware({
  "GET /weather": {
    accepts: { scheme: "exact", price: "$0.01",
               network: "stellar:testnet", payTo },
    description: "Current weather for a city",
  },
}, server));
4Name the route and its price
08The Bazaar

Make one sale, and you're on the shelf.

The Bazaar is a catalog of every API and MCP tool paid through Rail402. A listing appears by itself after its first payment, and agents search it in plain words.

  • Only the seller who got paid can change a listing.
  • Search by meaning, price, network or type.
  • Off chain: listing costs no extra transaction.
Search and discovery →
Current weatherHTTP · 0.001 USDC
Translate a textHTTP · 0.002 USDC
ForecastMCP tool · 0.001 USDC
Pet photo to sketchHTTP · 0.25 USDC
Weather historyupto · ≤ 0.01 USDC
just listedYour APIafter its first sale
GET testnet.rail402.dev/discovery/search?query=weather+under+1+cent
09Search quality

Ask in your own words. Get the right tool.

Bazaar search mixes keywords with meaning, so a question finds the right tool even when it uses different words than the listing. We test it on 500 listings and 202 questions, and publish the scores.

  • Better than keyword search alone on every score.
  • Filters always hold: 0 results over your price, network or type.
  • About 5 ms per search. Any drop in quality fails our build.
Read the evaluation →
keywords onlyRail402 search
Top 10 ranking · nDCG@100.677 → 0.742
Found in top 20 · Recall@200.821 → 0.897
Right answer first · P@10.741 → 0.815
First right answer · MRR0.823 → 0.881
500listings in the test
202questions, scored
0filter violations
10For AI agents

Give your agent pocket money.

Add the Rail402 MCP server to Claude, Cursor or any MCP app. Your agent searches the Bazaar, pays for the tool it needs and keeps the receipt, even for tools it was never told about.

  • Caps per call and per day, checked before anything is signed.
  • On mainnet it pays only verified sellers, and asks you before its first payment.
  • The wallet key stays in a file. The model never sees it.
Set up the MCP server →
  agent sessionrail402-mcp
What's the weather in Istanbul right now?
search_stellar_resourcesquery: "current weather for a city"
pay_and_callCurrent weather for a city · 0.001 USDC
paid · settled on Stellar0.001 USDCreceipt b6f035f9…75afbudget left 0.999 of 1 USDC
It's 21° and sunny in Istanbul.
11Agent budgets

Give every agent a wallet with rules.

An agent can pay from a plain key, or from a smart account with a budget written into it. Then the account itself refuses anything over the limit, so even a leaked agent key can't spend more than you allowed.

  • Payments inside the budget settle as usual.
  • A payment over what's left is refused, and nothing moves.
  • The agent's key can't switch to a rule without the budget.

Works with OpenZeppelin smart accounts. Our budget policy is an example in the repository, proven by tests on testnet.

Smart accounts and budgets →
agent budget · C…limit 1.00 USDC
0.20 USDC left
spent 0.801.00
PAIDforecast · 0.25 USDC
PAIDtranslate · 0.25 USDC
PAIDsketch · 0.30 USDC
REFUSED0.40 USDC > 0.20 left · nothing moved
12Playground

Try it in your browser. No install.

The Playground makes a test wallet for you with free test USDC on Stellar's testnet. Make a real payment and watch every message, signature and transaction, from the 402 to the receipt.

playground.rail402.dev
A wallet, made for you1 test USDC, free
Pick somethingfrom the Bazaar
Sign and paysee every message
Open the receipta real transaction
13Explorer

Every x402 payment on Stellar, in one place.

The Explorer shows x402 payments on mainnet and testnet: who paid whom, how much, with which scheme and through which facilitator. Paste a transaction hash and see the whole payment.

  • Every ledger is checked against its own hashes before it is shown.
  • The Ecosystem Report counts payments across facilitators.
  • Anyone can rebuild it from public ledgers. Nothing to take on trust.
Open the Explorer →
explorer.rail402.dev
b6f035f9948c43519bcf438e2bba4cee60c08be1…
schemeexact
paid0.0010000 USDC
from → tobuyer → GBSV…ELYP
facilitatorRail402 · fee sponsored
resourcedemo.rail402.dev/weather
ledger✓ hashes verified
14Trust and proof

We never touch the money. You can check.

USDC moves from buyer to seller in one Stellar transaction, and Rail402 only pays the fee. Every payment has a public transaction hash you can check on Stellar yourself.

  • Published threat model and operational tests
  • Recorded test runs with real transaction hashes
  • Every refusal has a stable error code you can look up
Read the threat model →
paid0.0010000 USDC
toGBSV…ELYP
network feepaid by Rail402
15Clear refusals

Every "no" comes with a reason.

When Rail402 refuses something, it never just says "error". Each code has a fixed name, an HTTP status, a plain reason and a flag that says whether trying again can work. Tests pin all of them, so your code can rely on them.

  • Branch on the code. Show the reason to people.
  • A reason can never be empty.
  • A code never changes without a changelog entry.
All error codes →
POST /verifyrefused
codeinvalid_exact_stellar_payload_facilitator_is_payer
status400
retry?no
reasonThe transfer's from address is a facilitator account.
325codes across the facilitator, Bazaar, search, SDK, MCP server and CLI
16Run it your way

Use ours, or run your own.

The same facilitator runs in three ways. Your sellers and buyers don't notice the difference: they only see a URL.

hosted

Point at our URL

Nothing to run. Free on testnet; mainnet with an API key.

https://testnet.rail402.dev
https://mainnet.rail402.dev
docker

Your own server

One command builds the image, funds a testnet sponsor and starts Postgres and the service.

$ ./deploy/docker.sh
in-process

Inside your app

Import the facilitator into your own Node server. No network hop.

$ npm i @rail402.dev/facilitator

Whichever you pick, you get

You choose what it accepts

Turn testnet and mainnet on or off, and list the tokens you take. USDC is the default.

You set the limits

Fees, rate limits and per-key quotas are settings, never fixed in the code.

Mainnet won't start half-set

If a mainnet setting is missing or unsafe, the service refuses to start instead of guessing.

Keys stay in files

Secret keys are read from files on your machine, not pasted into settings or logs.

Easy to watch

Built-in health, readiness and metrics pages for your monitoring.

17The toolkit

Everything ships on npm.

Open source under Apache-2.0, version 0.5.7. Take one package, or the whole rail.

the front door

sdk

Pay, search and sell from your code. Every payment needs a spending cap.

npm →
the terminal

cli

Make a wallet, search the Bazaar and buy, right from your terminal.

npm →
for agents

mcp

Lets Claude, Cursor or any MCP app search and pay under a cap.

npm →
the engine

facilitator

Verify and settle payments, as a service or inside your server.

npm →
the catalog

bazaar

Listings that appear after a sale, with integrity checks.

npm →
metered

upto

The upto scheme: buyer, seller and facilitator sides.

npm →
the contract

errors

Every code and reason, shared by all of Rail402.

npm →
also

stellar · search · safe-fetch · store-postgres · x402-index

18Start building

Pick your side of the payment.

Live on Stellar mainnet, free on testnet. Use our hosted facilitator or run your own: nothing depends on us.

Sell an API

Add one middleware, name a price, get paid per call.

$ npm i @x402/express @x402/stellar
Seller quickstart →

Pay as a buyer or agent

Find and pay any listing from your terminal or code.

$ npm i -g @rail402.dev/cli
$ rail402 purchase "current weather"
CLI and SDK →

Give your agent a wallet

Add the MCP server to Claude, Cursor or any MCP app.

$ npm i -g @rail402.dev/mcp
MCP server →
Mainnetmainnet.rail402.dev · API key
Testnettestnet.rail402.dev · free, no key
Open sourceApache-2.0 · github.com/tolgayayci/rail402

Ask. Pay. Get the answer.

Start on testnet for free, then switch to mainnet when you're ready.