@aeon-ai-pay/x402
v0.0.22
Published
Aeon's x402 open protocol for blockchain-native payments
Maintainers
Readme
@aeon-ai-pay/x402
Aeon's x402 open protocol for blockchain-native payments.
Features
- Support for multiple payment schemes (exact, subscription)
- Support for multiple blockchains (EVM, Solana)
- Middleware for Express and Next.js
- Static HTML paywall bundle for serving directly from middleware
Installation
npm install @aeon-ai-pay/x402Usage
Next.js Middleware
import { x402NextMiddleware } from '@aeon-ai-pay/x402/middleware';
// Configure the middleware
const middleware = x402NextMiddleware({
facilitatorUrl: 'https://facilitator.aeon.xyz',
routes: {
'/api/protected': {
paymentRequirements: [
{
scheme: 'exact',
namespace: 'evm',
networkId: 'base',
payTo: '0x...',
maxAmountRequired: 100000000, // 100 USDC (6 decimals)
maxTimeoutSeconds: 3600,
resource: '/api/protected',
description: 'Access to protected API',
}
]
}
}
});
// Export the middleware
export { middleware };Static HTML Paywall Bundle
The package now includes a static HTML paywall bundle that can be served directly from the middleware when a 402 status is encountered, instead of redirecting to a paywall route.
To build the static HTML paywall bundle:
npm run build:paywallThis will build the paywall-app with static export and copy the output to the src/shared/paywall/paywallHtml.ts directory.
The middleware will automatically serve the static HTML bundle when a 402 status is encountered.
Documentation
For more detailed documentation, see the scripts/README.md file.
License
Apache-2.0
