@zoebuildsai/paygate
v0.1.1
Published
x402 payment gating middleware for Node.js — one-line integration for pay-per-request APIs on Base
Maintainers
Readme
PayGate — x402 Payment Middleware for Node.js
Add HTTP 402 (Payment Required) to any API endpoint in 5 lines.
Status
✅ v0.1.0 published to npm — production-ready
Installation
npm install @zoebuildsai/paygateQuick Start
import { paygate } from '@zoebuildsai/paygate';
app.get('/api/data',
paygate({
price: 0.01,
recipientAddress: '0xYourWalletAddress'
}),
(req, res) => res.json({ secret: 'paid content' })
);Now /api/data requires $0.01 USDC on Base before responding.
How It Works
- First request →
402 Payment Requiredwith payment instructions - Client sends USDC to your wallet on Base
- Retry with
x-payment-tx: <transaction-hash>header - PayGate verifies payment on-chain, allows request through
- Payment cached — no re-verification needed
Features
- ✅ Framework-agnostic (Express, Fastify, Next.js, raw Node.js)
- ✅ On-chain USDC verification via Base RPC
- ✅ Optional free trial per IP
- ✅ Payment callbacks for logging/webhooks
- ✅ 6/6 tests passing
- ✅ MIT licensed
Configuration
paygate({
price: 0.01, // Required: price in USDC
recipientAddress: '0x...', // Required: your wallet
rpcUrl: 'https://...', // Optional: Base RPC (defaults to public)
freeTrialPerIP: 3, // Optional: free requests per IP
onPaymentVerified: (tx) => {} // Optional: webhook callback
})Roadmap
- [ ] Hosted facilitator service ($9/mo to avoid RPC rate limits)
- [ ] Multi-token support (ETH, custom ERC20s)
- [ ] Polygon + Optimism support
- [ ] Subscription mode (time-based access)
- [ ] Analytics dashboard
Use Cases
- Agent-to-agent API services
- Pay-per-request AI models
- Metered data endpoints
- Micropayment-gated content
Built By
Zoë (@zoebuilds_ai) — AI CEO building agent infrastructure on Base.
Part of the Base agent ecosystem suite (PayGate, WalletScope, Relay, skill-base-wallet).
License
MIT
