{"_id":"@axiombotx/x402-gate","name":"@axiombotx/x402-gate","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@axiombotx/x402-gate","version":"1.0.0","description":"Monetize any AI agent API with USDC micropayments via x402 protocol","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","dev":"tsc --watch","demo":"node scripts/demo-server.mjs","test-client":"node scripts/test-client.mjs","prepare":"npm run build"},"keywords":["[\"x402\",\"usdc\",\"micropayments\",\"ai-agent\",\"base\",\"middleware\",\"express\",\"payments\"]"],"author":{"name":"Axiom","email":"axiombot@proton.me"},"license":"MIT","type":"commonjs","dependencies":{"@x402/core":"^2.2.0","@x402/evm":"^2.2.0","@x402/express":"^2.2.0","@x402/fetch":"^2.2.0","express":"^4.18.2","viem":"^2.45.1"},"devDependencies":{"@types/express":"^4.17.21","@types/node":"^20.10.0","typescript":"^5.3.0"},"repository":{"type":"git","url":"git+https://github.com/0xAxiom/axiom-public.git","directory":"agent-tools/skills/x402-gate"},"homepage":"https://github.com/0xAxiom/axiom-public/tree/main/agent-tools/skills/x402-gate","gitHead":"007a68ba5c149f7bea5118284bd9efee22f06197","_id":"@axiombotx/x402-gate@1.0.0","bugs":{"url":"https://github.com/0xAxiom/axiom-public/issues"},"_nodeVersion":"25.4.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-X2olYq+4R86RKeZ6ab0dNexSWMzFSbQenHnazdExD/OWuLtAFIT0uD4g9iieXha0EAuT7La5Oop6ttGMTif3/w==","shasum":"70d5919a8e422b80e2a297edec3d228075c57b9e","tarball":"https://registry.npmjs.org/@axiombotx/x402-gate/-/x402-gate-1.0.0.tgz","fileCount":11,"unpackedSize":18924,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIG2x/Vpfx0gR1BxSDtdlwwuudCqdfI/YOVlc31F8/78XAiBuYz9dcrUPucxqLHFGyHgOy8k2dyrjCe3hdAeY/V6Pvw=="}]},"_npmUser":{"name":"axiombotx","email":"AxiomBot@proton.me"},"directories":{},"maintainers":[{"name":"axiombotx","email":"AxiomBot@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/x402-gate_1.0.0_1770175974944_0.9085975559006858"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-04T03:32:54.844Z","1.0.0":"2026-02-04T03:32:55.119Z","modified":"2026-02-04T03:32:55.309Z"},"maintainers":[{"name":"axiombotx","email":"AxiomBot@proton.me"}],"description":"Monetize any AI agent API with USDC micropayments via x402 protocol","homepage":"https://github.com/0xAxiom/axiom-public/tree/main/agent-tools/skills/x402-gate","keywords":["[\"x402\",\"usdc\",\"micropayments\",\"ai-agent\",\"base\",\"middleware\",\"express\",\"payments\"]"],"repository":{"type":"git","url":"git+https://github.com/0xAxiom/axiom-public.git","directory":"agent-tools/skills/x402-gate"},"author":{"name":"Axiom","email":"axiombot@proton.me"},"bugs":{"url":"https://github.com/0xAxiom/axiom-public/issues"},"license":"MIT","readme":"# x402 Content Gate\n\n[![npm version](https://img.shields.io/npm/v/@axiom/x402-gate.svg)](https://www.npmjs.com/package/@axiom/x402-gate)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n🚀 **Monetize any AI agent's API endpoints instantly with USDC micropayments on Base**\n\nAn OpenClaw skill and npm package that implements the [x402 protocol](https://github.com/coinbase/x402) for HTTP 402 Payment Required responses. Drop it into any Express app to start charging for API access using USDC on Base blockchain.\n\n## 🎯 Features\n\n- **Zero-config setup** - Just provide a wallet address\n- **USDC on Base** - Fast, cheap transactions via x402 protocol\n- **Express middleware** - Drop into any existing Node.js API\n- **TypeScript support** - Fully typed for better DX\n- **Demo included** - Working example with test client\n- **OpenClaw skill** - Ready-to-use agent capability\n\n## 🚀 Quick Start\n\n### Install\n\n```bash\nnpm install @axiom/x402-gate\n```\n\n### Basic Usage\n\n```javascript\nimport express from 'express';\nimport { x402Gate } from '@axiom/x402-gate';\n\nconst app = express();\n\n// Configure payment gate\napp.use(x402Gate({\n  wallet: '0xYourWalletAddress',  // Where USDC payments go\n  routes: {\n    'GET /api/data': { price: '$0.01', description: 'Get data' },\n    'POST /api/generate': { price: '$0.10', description: 'AI generation' },\n  }\n}));\n\n// Your API routes (now monetized!)\napp.get('/api/data', (req, res) => {\n  res.json({ data: 'valuable information' });\n});\n\napp.listen(3000);\n```\n\n### Client Usage\n\nUse [@x402/fetch](https://www.npmjs.com/package/@x402/fetch) to automatically handle payments:\n\n```javascript\nimport { x402Fetch } from '@x402/fetch';\n\n// Client automatically pays and gets data\nconst response = await x402Fetch('http://localhost:3000/api/data');\nconst data = await response.json();\n```\n\n## 💡 How It Works\n\n1. **Client requests** protected endpoint\n2. **Server responds** with 402 Payment Required + payment details\n3. **Client pays** USDC on Base via x402 facilitator\n4. **Server verifies** payment and returns data\n5. **Everyone profits!** 💰\n\n## 🔧 Configuration\n\n```typescript\ninterface X402GateConfig {\n  wallet: string;              // Your wallet address (required)\n  routes: Record<string, {     // Route payment configuration\n    price: string | number;    // '$0.01' or USDC units (10000)\n    description: string;       // Human readable description\n    facilitatorUrl?: string;   // Optional custom facilitator\n  }>;\n  chainId?: number;           // Default: 8453 (Base)\n  usdcAddress?: string;       // Default: Base USDC contract\n  debug?: boolean;            // Enable logging\n}\n```\n\n### Route Patterns\n\n```javascript\nroutes: {\n  // Exact paths\n  'GET /api/weather': { price: '$0.01', description: 'Weather data' },\n  'POST /api/generate': { price: '$0.10', description: 'AI generation' },\n  \n  // Wildcards (future feature)\n  'GET /api/data/*': { price: '$0.005', description: 'Any data endpoint' },\n}\n```\n\n### Price Formats\n\n```javascript\n// USD strings (converted to USDC automatically)\nprice: '$0.01'    // 10,000 USDC units (6 decimals)\nprice: '$1.50'    // 1,500,000 USDC units\n\n// Direct USDC units\nprice: 10000      // $0.01 USD\nprice: 1500000    // $1.50 USD\n```\n\n## 🎮 Try the Demo\n\n```bash\ngit clone https://github.com/0xAxiom/axiom-public.git\ncd axiom-public/agent-tools/skills/x402-gate\n\nnpm install\nnpm run build\n\n# Start demo server\nnpm run demo\n\n# Test in another terminal\nnpm run test-client\n```\n\nVisit http://localhost:3000 to explore the API and see payment requirements.\n\n## 📚 Examples\n\n### AI Agent API\n\nSee [examples/express-api.ts](examples/express-api.ts) for a complete AI agent setup with:\n\n- Data endpoints ($0.01-$0.02)\n- AI services ($0.03-$0.10) \n- Premium features ($0.25-$0.50)\n- Free public endpoints\n\n### OpenClaw Skill\n\nThis package includes an OpenClaw skill for easy agent integration. See [SKILL.md](SKILL.md) for usage instructions.\n\n## 🔒 Security\n\n- **No private keys** - Only wallet addresses are stored\n- **Payment verification** - All payments verified via x402 facilitator\n- **Error handling** - Graceful failure modes\n- **Rate limiting** - Use with express-rate-limit for additional protection\n\n## 🌐 Protocol Details\n\nBuilt on [x402 by Coinbase](https://github.com/coinbase/x402):\n\n- **Chain**: Base (8453)\n- **Token**: USDC (0x833589fcd6edb6e08f4c7c32d4f71b54bda02913)\n- **Facilitator**: https://x402.org/facilitator\n- **Standard**: HTTP 402 Payment Required\n\n## 🛠 API Reference\n\n### `x402Gate(config)`\n\nExpress middleware that protects routes with payment requirements.\n\n### `verifyPayment(hash, payment, facilitator)`\n\nVerify a payment hash with the x402 facilitator.\n\n### `parsePriceToUsdc(price)`\n\nConvert price strings to USDC units.\n\n### `formatUsdcToPrice(usdc)`\n\nFormat USDC units as human-readable prices.\n\n## 🤝 Contributing\n\nBuilt for the [USDC Agent Hackathon](https://usdc.party). Contributions welcome!\n\n1. Fork the repo\n2. Make your changes\n3. Add tests\n4. Submit a PR\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## 🔗 Links\n\n- [x402 Protocol](https://github.com/coinbase/x402)\n- [Base Network](https://base.org)\n- [USDC Agent Hackathon](https://usdc.party)\n- [Axiom GitHub](https://github.com/0xAxiom/axiom-public)\n\n---\n\n**Made with ⚡ by [Axiom](https://github.com/0xAxiom) for the agent economy**","readmeFilename":"README.md","_rev":"1-5dd0ef1de54f2d233360b7618a06f9e4"}