Installation
Plugin Registration
Route Filtering with paths
When the paths array is provided, the plugin intercepts only routes that match the specified prefixes. Unmatched routes pass through without paywall checks.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Fastify plugin for HTTP 402 paywalls on Stellar
pnpm add @stellar-x402/core @stellar-x402/fastify
import Fastify from 'fastify';
import { fastifyX402 } from '@stellar-x402/fastify';
const fastify = Fastify();
await fastify.register(fastifyX402, {
price: '0.02',
asset: 'CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC',
recipient: 'GCALKSGAZRJLSUEJT3M5W6LN4R7XQOLIRCOS6ZA6EDZVTZDBIIPPFKJ6',
network: 'stellar:testnet',
paths: ['/api/v1/premium'],
});
fastify.get('/api/v1/premium', async (req) => {
return {
payer: req.x402Payment?.payer,
status: 'access_granted',
};
});
await fastify.listen({ port: 3000 });
pathspaths array is provided, the plugin intercepts only routes that match the specified prefixes. Unmatched routes pass through without paywall checks.