@x1pay/middleware
v0.3.0
Published
x402 payment middleware for Express, Hono, Fastify, and Next.js
Maintainers
Readme
@x1pay/middleware
Express middleware for x402 paywalled API endpoints on X1 blockchain.
Install
npm install @x1pay/middlewareUsage (Express)
import express from 'express'
import { x402 } from '@x1pay/middleware'
const app = express()
app.use('/api/premium', x402({
payTo: 'YOUR_WALLET_ADDRESS',
amount: '100000',
tokenMint: 'USDX',
network: 'x1-mainnet',
facilitatorUrl: 'https://x1pays.xyz/facilitator-alpha-mainnet',
}))
app.get('/api/premium/data', (req, res) => {
res.json({ data: 'premium content' })
})
app.listen(3000)Clients without a valid payment header receive HTTP 402 with payment terms. Clients with @x1pay/sdk pay automatically.
License
MIT
