Stellar x402

@402-stellar is built to empower builders, creators, and people everywhere to build apps, grow businesses, create what they love, and earn onchain.

Get Started

Install @402-stellar and start building internet-native payments

terminal — zsh
~

Express middleware for instant payments.

Protect your API routes with x402-stellar-express. Monetize your data, AI models, and content with just a few lines of code.

1
import express from "express";
2
import { paymentMiddleware } from "x402-stellar-express";
3
4
const app = express();
5
6
// Protect routes with payments
7
app.use(
8
paymentMiddleware({
9
payTo: "GXXXX...",
10
routes: {
11
"/api/premium/*": { price: "1.00" },
12
"/api/data": { price: "0.50" },
13
},
14
})
15
);

Easy Integration

Add payment protection to any Express route with a single middleware. Configure prices per route or pattern.

1
paymentMiddleware({
2
payTo: "GXXXX...",
3
routes: {
4
"/api/premium/*": {
5
price: "1.00",
6
asset: "native",
7
description: "Premium API",
8
maxTimeoutSeconds: 300
9
}
10
},
11
network: "stellar-testnet"
12
})

Flexible Configuration

Customize assets, networks, timeouts, and more. Configure extensive options to fit your business model.

Powerful primitives for
programmable money.

Visualizing how x402-stellar-express handles the heavy lifting of payment logic, verification, and settlement.

GET
402
PAY
200

HTTP 402 Protocol

Standardized flow: Request ➔ 402 Challenge ➔ Payment ➔ Resource Access.

Settling...0%
Processing Transaction

Instant Settlement

Payments settle on the Stellar network in 3-5 seconds with near-zero fees.

app.use(
paymentMiddleware({
routes: {
"/api/*": "1.00"// 1 XLM
},
payTo: "G..."
})
)

Simple Configuration

Define routes, prices, and assets directly in your Express middleware.

Cryptographic Verification

Middleware automatically verifies transaction signatures and validity.

XLM
USDC
EURC

Multi-Asset Support

Accept payments in native XLM or any Stellar ecosystem token (USDC, EURC).

Error: Payment Required
Auto-Retry

Automated Error Handling

Gracefully handles timeouts, insufficient funds, and network errors.

Real Use Case Ideas

See how developers are using @402-stellar to build the future of web monetization

API Monetization
API MONETIZATION

API Monetization

Charge per-request for your APIs without complex subscription models. Pay-per-use made simple.

Content Access and Subscription Mechanism
CONTENT ACCESS

Content Access and Subscription Mechanism

Gate premium content, articles, or media with instant micropayments. No accounts required. Seamless subscription management.

Enterprise Solutions
SECURITY LAYER

Enterprise Solutions

Deploy permissioned payment rails for B2B integrations with full audit trails and enterprise-grade security.