Skip to content

Commit 9e72fd1

Browse files
committed
Merge branch 'main' of github.com:stellar/stellar-docs into chore/update-packages
2 parents 34833e3 + 1882069 commit 9e72fd1

24 files changed

Lines changed: 987 additions & 90 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: "Use the x402 protocol for per-request HTTP payments on Stellar, wi
99

1010
x402 is an open protocol from the Coinbase Developer Platform that enables programmatic, per request payments over HTTP, designed especially for AI agents and APIs. It effectively turns the old “402 Payment Required” HTTP status code into something usable, for both humans and AI agents.
1111

12-
On Stellar, x402 works with Soroban authorization so that clients can pay for API requests via signed auth entries, ideal for micropayments and payment enabled apps. To build an x402-enabled service or integrate payments into your app, see [Build Applications](./README.mdx) and the resources below.
12+
On Stellar, x402 works with Soroban authorization so that clients can pay for API requests via signed auth entries, ideal for micropayments and payment enabled apps. To build an x402-enabled service or integrate payments into your app, see [Build Applications](../README.mdx) and the resources below.
1313

1414
## Demo
1515

@@ -19,7 +19,7 @@ Try the [x402 Demo](https://stellar.org/x402-demo). Send an x402 payment on Stel
1919

2020
## x402 Compatible Wallets
2121

22-
To support x402 on Stellar, a wallet must support [auth-entry signing](../guides/transactions/signing-soroban-invocations.mdx#method-2-auth-entry-signing) (Soroban authorization entry signing). The following wallets support auth-entry signing:
22+
To support x402 on Stellar, a wallet must support [auth-entry signing](../../guides/transactions/signing-soroban-invocations.mdx#method-2-auth-entry-signing) (Soroban authorization entry signing). The following wallets support auth-entry signing:
2323

2424
- Freighter Browser Extension
2525
- Albedo
@@ -95,4 +95,4 @@ This version supports x402 v2 specification. For x402 v1 support, please use a p
9595
- [x402 protocol specification](https://www.x402.org/) — x402 Specification and Whitepaper
9696
- [Coinbase x402 GitHub](https://github.com/coinbase/x402) — Official x402 Protocol GitHub Repo
9797
- [x402-stellar (npm)](https://www.npmjs.com/package/x402-stellar) — npm package for x402 on Stellar
98-
- [Signing Soroban invocations](../guides/transactions/signing-soroban-invocations.mdx) — Auth-entry signing and transaction signing on Stellar
98+
- [Signing Soroban invocations](../../guides/transactions/signing-soroban-invocations.mdx) — Auth-entry signing and transaction signing on Stellar
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"collapsed": false
3+
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
title: Built on Stellar x402 Facilitator
3+
sidebar_position: 10
4+
sidebar_label: Built on Stellar Facilitator
5+
description: "Free, public x402 facilitator for Stellar with ~5-second finality and sponsored fees. Full verification and settlement flow powered by the OpenZeppelin Relayer."
6+
---
7+
8+
The **Built on Stellar** x402 Facilitator is a production-ready payment facilitator for the [x402 protocol](./README.mdx) on Stellar. It handles payment verification and settlement so that sellers can accept per-request payments without running their own blockchain infrastructure.
9+
10+
Built with the [OpenZeppelin Relayer][oz-relayer] and the [x402 Facilitator Plugin][oz-plugin], it exposes the standard x402 `/verify`, `/settle`, and `/supported` endpoints and is fully compatible with the [Coinbase x402 ecosystem][x402-ecosystem].
11+
12+
## Key information
13+
14+
| | Testnet | Mainnet |
15+
| --- | --- | --- |
16+
| **Facilitator URL** | `https://channels.openzeppelin.com/x402/testnet` | `https://channels.openzeppelin.com/x402` |
17+
| **API key generation** | [Generate testnet key](https://channels.openzeppelin.com/testnet/gen) | [Generate mainnet key](https://channels.openzeppelin.com/gen) |
18+
| **x402 version** | v2 | v2 |
19+
| **x402 scheme** | `exact` | `exact` |
20+
| **Supported assets** | Any [SEP-41] token (defaults to USDC) | Any [SEP-41] token (defaults to USDC) |
21+
22+
## Get started
23+
24+
### 1. Generate an API key
25+
26+
Generate an API key for the network you want to use:
27+
28+
- **Testnet**: https://channels.openzeppelin.com/testnet/gen
29+
- **Mainnet**: https://channels.openzeppelin.com/gen
30+
31+
### 2. Configure the facilitator URL
32+
33+
Use the facilitator URL in your x402 server configuration. Here's an example using `@x402/express`:
34+
35+
```typescript
36+
import express from "express";
37+
import { paymentMiddleware, x402ResourceServer } from "@x402/express";
38+
import { ExactStellarScheme } from "@x402/stellar/exact/server";
39+
import { HTTPFacilitatorClient } from "@x402/core/server";
40+
41+
const facilitatorClient = new HTTPFacilitatorClient({
42+
url: "https://channels.openzeppelin.com/x402/testnet",
43+
createAuthHeaders: async () => {
44+
const headers = { Authorization: `Bearer YOUR_API_KEY` };
45+
return { verify: headers, settle: headers, supported: headers };
46+
},
47+
});
48+
49+
const app = express();
50+
51+
app.use(
52+
paymentMiddleware(
53+
{
54+
"GET /weather": {
55+
accepts: [
56+
{
57+
scheme: "exact",
58+
price: "$0.001",
59+
network: "stellar:testnet",
60+
payTo: "SERVER_STELLAR_ADDRESS",
61+
},
62+
],
63+
description: "Weather data",
64+
mimeType: "application/json",
65+
},
66+
},
67+
new x402ResourceServer(facilitatorClient).register(
68+
"stellar:testnet",
69+
new ExactStellarScheme(),
70+
),
71+
),
72+
);
73+
74+
app.get("/weather", (req, res) => {
75+
res.send({ weather: "sunny", temperature: 70 });
76+
});
77+
78+
app.listen(4021);
79+
```
80+
81+
#### Pricing formats
82+
83+
The `price` field supports two formats:
84+
85+
**Human-readable** — A dollar-string like `"$0.001"`. The x402 SDK converts this to the equivalent on-chain amount and assumes USDC on Stellar.
86+
87+
```typescript
88+
price: "$0.001";
89+
```
90+
91+
**Explicit asset and amount** — Specify the on-chain [SEP-41] asset contract address and the amount in base units (the smallest unit as defined by the token's `decimals`; for example, if a USDC token has 7 decimals, then 1 USDC = 10,000,000 base units).
92+
93+
```typescript
94+
price: {
95+
asset: "CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA",
96+
amount: "10000",
97+
};
98+
```
99+
100+
Use the explicit format when you want to accept a specific asset other than USDC, or when you need precise control over the on-chain amount.
101+
102+
### 3. Accept payments
103+
104+
With the middleware in place, any request to a protected route will trigger the x402 payment flow:
105+
106+
1. The client requests the resource
107+
2. The server responds with `402 Payment Required` and a `PAYMENT-REQUIRED` header containing the payment instructions (price, network, facilitator URL)
108+
3. The client signs a Soroban authorization entry and resubmits the request with a `PAYMENT-SIGNATURE` header
109+
4. The facilitator verifies and settles the payment on-chain
110+
5. The server returns the resource along with a `PAYMENT-RESPONSE` header confirming settlement
111+
112+
## How it works
113+
114+
The Built on Stellar facilitator leverages the OpenZeppelin Relayer framework with the x402 Facilitator Plugin. Under the hood, it uses the [OpenZeppelin Relayer][oz-relayer] for high-throughput transaction submission.
115+
116+
### Verification
117+
118+
When a payment is received, the facilitator:
119+
120+
1. Validates the x402 protocol version, scheme, and network
121+
2. Decodes the transaction XDR and checks it is an `invokeHostFunction` calling `transfer`
122+
3. Confirms the amount and recipient match the payment requirements
123+
4. Verifies the authorization entries are properly signed by the payer
124+
5. Simulates the transaction on-chain to confirm it will succeed
125+
126+
### Settlement
127+
128+
After verification, the facilitator submits the payment on-chain via the OpenZeppelin Relayer and returns confirmation to the server.
129+
130+
## Supported features
131+
132+
- **Networks**: `stellar:testnet`, `stellar:pubnet` ([CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md) identifiers)
133+
- **Assets**: Any [SEP-41] token asset (defaults to USDC)
134+
- **x402 scheme**: `exact-v2`
135+
- **Endpoints**: `/verify`, `/settle`, `/supported`
136+
- **Settlement**: Managed on-chain submission via [OpenZeppelin Relayer][oz-relayer]
137+
- **Compatibility**: Works with all [x402 ecosystem packages][x402-ecosystem] and [Stellar x402-compatible wallets](./README.mdx#x402-compatible-wallets)
138+
139+
## Self-hosting
140+
141+
If you want to run your own instance of the facilitator instead of using the hosted service, you can deploy the OpenZeppelin Relayer with the x402 Facilitator Plugin directly. See the [OpenZeppelin x402 Facilitator guide][oz-facilitator-guide] and the [plugin source code][oz-plugin] for setup instructions.
142+
143+
## Resources
144+
145+
- [@x402/stellar (npm)](https://www.npmjs.com/package/@x402/stellar) — npm package for x402 on Stellar
146+
- [x402-stellar (repo)](https://github.com/stellar/x402-stellar) — Tools, examples, and references for x402 on Stellar
147+
- [x402 on Stellar](./README.mdx) — Overview of the x402 protocol on Stellar
148+
- [x402 protocol specification](https://www.x402.org/) — x402 specification and whitepaper
149+
- [OpenZeppelin x402 Facilitator Plugin][oz-plugin] — Source code
150+
- [OpenZeppelin x402 Facilitator Docs][oz-facilitator-guide] — Full configuration and setup guide
151+
- [OpenZeppelin Stellar Relayer SDK](https://github.com/OpenZeppelin/openzeppelin-relayer-sdk) — SDK for interacting with the Relayer
152+
153+
[oz-relayer]: https://docs.openzeppelin.com/relayer/1.4.x
154+
[oz-plugin]: https://github.com/OpenZeppelin/relayer-plugin-x402-facilitator
155+
[oz-facilitator-guide]: https://docs.openzeppelin.com/relayer/1.4.x/guides/stellar-x402-facilitator-guide
156+
[SEP-41]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0041.md
157+
[x402-ecosystem]: https://github.com/coinbase/x402

0 commit comments

Comments
 (0)