Monetize your API.
Drop one Express middleware on a route. An unpaid request gets a 402 Payment Required with the price and chains you accept. The handler only runs after USDC has settled.
import { x402Middleware } from '@dexterai/x402/server';
app.get('/api/data',
x402Middleware({
payTo: 'YourAddress...',
amount: '0.01',
}),
(req, res) => {
res.json({ data: 'protected content' });
}
);- Signature verification, settlement, and response all handled
- One address or per-chain routing via
payToobject - Accept one chain or a list: Solana, Base, Polygon, Arbitrum, Optimism, Avalanche, SKALE