Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 8 additions & 29 deletions docs/build/apps/x402.mdx → docs/build/apps/x402/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: "Use the x402 protocol for per-request HTTP payments on Stellar, wi

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.

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.
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.

## Demo

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

## x402 Compatible Wallets

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:
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:

- Freighter Browser Extension
- Albedo
Expand All @@ -44,33 +44,11 @@ Coinbase’s x402 facilitator supports Stellar on **Testnet** with sponsored fee

- **[x402 Facilitator Supported Networks](https://www.x402.org/facilitator/supported)** — Lists supported networks (including `stellar:testnet`) and facilitator configuration.

### Build on Stellar Relayer (with OpenZeppelin x402 Plugin)
### Built on Stellar x402 Facilitator

The [Relayer Plugin for x402](https://github.com/OpenZeppelin/relayer-plugin-x402-facilitator) implements the x402 Facilitator API so you can serve x402 payments directly from a Relayer instance. The x402 Facilitator leverages the OpenZeppelin Relayer Framework. It works with the [Coinbase x402](https://github.com/coinbase/x402) ecosystem and exposes the expected `/verify`, `/settle`, and `/supported` endpoints under the Relayer plugin router.
The [Built on Stellar x402 Facilitator](./built-on-stellar.mdx) is a production-ready facilitator for Stellar **Testnet and Mainnet**, powered by the [OpenZeppelin Relayer](https://docs.openzeppelin.com/relayer/1.4.x) and [Channels](https://docs.openzeppelin.com/relayer/1.4.x) infrastructure. It handles verification and settlement so you can accept x402 payments without running your own blockchain infrastructure.

#### How to Use

This x402 facilitator service is available on Testnet and Mainnet. Under the hood, the plugin leverages OpenZeppelin Channels to submit transactions onchain via a managed Relayer and Facilitator setup.

#### Testnet

To use the facilitator on testnet, you will need:

- An API Key (Relayer Service). Generate your testnet API key here: https://channels.openzeppelin.com/testnet/gen
- Facilitator URL. Use the following facilitator endpoint in your configuration: `https://channels.openzeppelin.com/x402/testnet`

#### Mainnet

To use the Facilitator on mainnet, you will need:

- An API Key (Relayer Service). Generate your mainnet API key here: https://channels.openzeppelin.com/gen
- Facilitator URL. Use the following facilitator endpoint in your configuration: `https://channels.openzeppelin.com/x402`

:::note

This version supports x402 v2 specification. For x402 v1 support, please use a previous version of this plugin (check git history for v1 compatible releases).

:::
See the [Built on Stellar Facilitator page](./built-on-stellar.mdx) for endpoints, API key generation, and a getting-started guide.

## Examples

Expand All @@ -91,8 +69,9 @@ This version supports x402 v2 specification. For x402 v1 support, please use a p

- [x402 on Stellar (Landing page)](https://stellar.org/x402) — Stellar x402 overview and resources
- [x402 on Stellar (Blog)](https://stellar.org/blog/foundation-news/x402-on-stellar) — Foundation news and announcement
- [@x402/stellar (npm)](https://www.npmjs.com/package/@x402/stellar) — npm package for x402 on Stellar
- [x402-stellar repo](https://github.com/stellar/x402-stellar) — Tools, examples, and references for x402 on Stellar
- [x402 protocol (Coinbase Developer Platform)](https://docs.cdp.coinbase.com/x402) — Official x402 protocol overview and spec
- [x402 protocol specification](https://www.x402.org/) — x402 Specification and Whitepaper
- [Coinbase x402 GitHub](https://github.com/coinbase/x402) — Official x402 Protocol GitHub Repo
- [x402-stellar (npm)](https://www.npmjs.com/package/x402-stellar) — npm package for x402 on Stellar
- [Signing Soroban invocations](../guides/transactions/signing-soroban-invocations.mdx) — Auth-entry signing and transaction signing on Stellar
- [Signing Soroban invocations](../../guides/transactions/signing-soroban-invocations.mdx) — Auth-entry signing and transaction signing on Stellar
188 changes: 188 additions & 0 deletions docs/build/apps/x402/built-on-stellar.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
title: Built on Stellar x402 Facilitator
sidebar_position: 10
sidebar_label: Built on Stellar Facilitator
description: "Free, public x402 facilitator for Stellar with ~5-second finality and sponsored fees. Full verification and settlement flow powered by the OpenZeppelin Relayer."
hide_title: true
---

<div
style={{
display: "flex",
alignItems: "center",
gap: "16px",
marginBottom: "16px",
}}
>
<img
src="/assets/x402/built-on-stellar-logo.png"
alt="Built on Stellar logo"
width="68"
height="68"
style={{ borderRadius: "8px", alignItems: "center", margin: 0 }}
/>
<h1
style={{
margin: 0,
marginTop: "20px",
fontSize: "48px",
lineHeight: "56px",
height: "56px",
Comment thread
marcelosalloum marked this conversation as resolved.
Outdated
display: "flex",
alignItems: "center",
}}
>
Built on Stellar x402 Facilitator
</h1>
</div>

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.

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].

## Key information

| | Testnet | Mainnet |
| --- | --- | --- |
| **Facilitator URL** | `https://channels.openzeppelin.com/x402/testnet` | `https://channels.openzeppelin.com/x402` |
| **API key generation** | [Generate testnet key](https://channels.openzeppelin.com/testnet/gen) | [Generate mainnet key](https://channels.openzeppelin.com/gen) |
| **x402 version** | v2 | v2 |
| **x402 scheme** | `exact` | `exact` |
| **Supported assets** | Any [SEP-41] token (defaults to USDC) | Any [SEP-41] token (defaults to USDC) |

## Get started

### 1. Generate an API key

Generate an API key for the network you want to use:

- **Testnet**: https://channels.openzeppelin.com/testnet/gen
- **Mainnet**: https://channels.openzeppelin.com/gen

### 2. Configure the facilitator URL

Use the facilitator URL in your x402 server configuration. Here's an example using `@x402/express`:

```typescript
import express from "express";
import { paymentMiddleware, x402ResourceServer } from "@x402/express";
import { ExactStellarScheme } from "@x402/stellar/exact/server";
import { HTTPFacilitatorClient } from "@x402/core/server";

const facilitatorClient = new HTTPFacilitatorClient({
url: "https://channels.openzeppelin.com/x402/testnet",
createAuthHeaders: async () => {
const headers = { Authorization: `Bearer YOUR_API_KEY` };
return { verify: headers, settle: headers, supported: headers };
},
});

const app = express();

app.use(
paymentMiddleware(
{
"GET /weather": {
accepts: [
{
scheme: "exact",
price: "$0.001",
network: "stellar:testnet",
payTo: "SERVER_STELLAR_ADDRESS",
},
],
description: "Weather data",
mimeType: "application/json",
},
},
new x402ResourceServer(facilitatorClient).register(
"stellar:testnet",
new ExactStellarScheme(),
),
),
);

app.get("/weather", (req, res) => {
res.send({ weather: "sunny", temperature: 70 });
});

app.listen(4021);
```

#### Pricing formats

The `price` field supports two formats:

**Human-readable** — A dollar-string like `"$0.001"`. The x402 SDK converts this to the equivalent on-chain amount and assumes USDC on Stellar.

```typescript
price: "$0.001";
```

**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).

```typescript
price: {
asset: "CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA",
amount: "10000",
};
```

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.

### 3. Accept payments

With the middleware in place, any request to a protected route will trigger the x402 payment flow:

1. The client requests the resource
2. The server responds with `402 Payment Required` and a `PAYMENT-REQUIRED` header containing the payment instructions (price, network, facilitator URL)
3. The client signs a Soroban authorization entry and resubmits the request with a `PAYMENT-SIGNATURE` header
4. The facilitator verifies and settles the payment on-chain
5. The server returns the resource along with a `PAYMENT-RESPONSE` header confirming settlement

## How it works

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.

### Verification

When a payment is received, the facilitator:

1. Validates the x402 protocol version, scheme, and network
2. Decodes the transaction XDR and checks it is an `invokeHostFunction` calling `transfer`
3. Confirms the amount and recipient match the payment requirements
4. Verifies the authorization entries are properly signed by the payer
5. Simulates the transaction on-chain to confirm it will succeed

### Settlement

After verification, the facilitator submits the payment on-chain via the OpenZeppelin Relayer and returns confirmation to the server.

## Supported features

- **Networks**: `stellar:testnet`, `stellar:pubnet` ([CAIP-2](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md) identifiers)
- **Assets**: Any [SEP-41] token asset (defaults to USDC)
- **x402 scheme**: `exact-v2`
Comment thread
marcelosalloum marked this conversation as resolved.
- **Endpoints**: `/verify`, `/settle`, `/supported`
- **Settlement**: Managed on-chain submission via [OpenZeppelin Relayer][oz-relayer]
- **Compatibility**: Works with all [x402 ecosystem packages][x402-ecosystem] and [Stellar x402-compatible wallets](./README.mdx#x402-compatible-wallets)

## Self-hosting

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.

## Resources

- [@x402/stellar (npm)](https://www.npmjs.com/package/@x402/stellar) — npm package for x402 on Stellar
- [x402-stellar (repo)](https://github.com/stellar/x402-stellar) — Tools, examples, and references for x402 on Stellar
- [x402 on Stellar](./README.mdx) — Overview of the x402 protocol on Stellar
- [x402 protocol specification](https://www.x402.org/) — x402 specification and whitepaper
- [OpenZeppelin x402 Facilitator Plugin][oz-plugin] — Source code
- [OpenZeppelin x402 Facilitator Docs][oz-facilitator-guide] — Full configuration and setup guide
- [OpenZeppelin Stellar Relayer SDK](https://github.com/OpenZeppelin/openzeppelin-relayer-sdk) — SDK for interacting with the Relayer

[oz-relayer]: https://docs.openzeppelin.com/relayer/1.4.x
[oz-plugin]: https://github.com/OpenZeppelin/relayer-plugin-x402-facilitator
[oz-facilitator-guide]: https://docs.openzeppelin.com/relayer/1.4.x/guides/stellar-x402-facilitator-guide
[SEP-41]: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0041.md
[x402-ecosystem]: https://github.com/coinbase/x402
1 change: 1 addition & 0 deletions routes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
/docs/build/apps/wallet/sep7
/docs/build/apps/wallet/stellar
/docs/build/apps/x402
/docs/build/apps/x402/built-on-stellar
/docs/build/apps/zk
/docs/build/guides
/docs/build/guides/archival
Expand Down
Binary file added static/assets/x402/built-on-stellar-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading