Add blockchain payments to your Express server with a single line of middleware
// Express server with BNB x402 payment middleware
import { paymentMiddleware } from 'x402';
import express from 'express';
const app = express();
// One line to accept payments
app.use(
paymentMiddleware("0xYourAddress", {
"/api/premium": "$0.01",
"/api/data": "$0.001"
})
);
// Your protected endpoints work automatically
app.get('/api/premium', (req, res) => {
res.json({ data: 'premium content' });
});x402 solves the shortcomings of existing payment systems with a simple, permissionless protocol
~2 second settlement with minimal fees. Perfect for micropayments and high-frequency transactions.
Facilitators never gain unilateral control of funds. Your money, your control.
Works with any blockchain. Extensible to new chains and signing schemes.
Payments carried alongside normal HTTP requests. No extra handshake required.
No reliance on a single provider. Permissionless and open source.
Clients and resource servers pay no gas fees via facilitator services.
Simple 4-step flow that integrates seamlessly with your existing HTTP infrastructure
Your application makes a standard HTTP request to a protected endpoint.
Resource server returns HTTP 402 with payment requirements and accepted options.
Client chooses a payment method and creates a signed payment payload.
Server verifies the payment (optionally via facilitator) and fulfills the request.
Choose your path to integrate x402 into your application
Install the package and run the example server in minutes
Read the full protocol specification and integration guides
Join the community and help build the future of web payments
No signup required. No platform fees. Just add one line of code.