{"_id":"@ace_won/x402","_rev":"3-850f57f458b03714c4610017e60118a4","name":"@ace_won/x402","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@ace_won/x402","version":"1.0.0","keywords":["x402","payment","middleware","nextjs","usdc","arc","arc-network","circle","micropayment","web3","eip-3009","conduit"],"author":{"name":"ace_won"},"license":"MIT","_id":"@ace_won/x402@1.0.0","maintainers":[{"name":"ace_won","email":"ace7coderr@gmail.com"}],"homepage":"https://conduit-pay.vercel.app/developers","bugs":{"url":"https://github.com/ace-coderr/conduit/issues"},"dist":{"shasum":"de82a7ad1d0b989d4370cafbc77df30827dc836c","tarball":"https://registry.npmjs.org/@ace_won/x402/-/x402-1.0.0.tgz","fileCount":6,"integrity":"sha512-+5+lRuNwCXJwUOh/vScWGpMxapT8sRu3MkAn+TKrFnGG1iDtT4deu/wo/IQ4iv6Eqgs7pHLZuijNoMKO4HuPPQ==","signatures":[{"sig":"MEYCIQC4PexfbWQd7a/BEHjQdxZ9P1HPtD74Iffb/i8+lic4EQIhAKI9N1maDROQd2oWrBhwVVfdyOVsiEWsZtS8V/Ax3rZz","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33805},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"f1679758dd418ebc4102050c5c2f82c89a991f6d","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","build":"tsup src/index.ts --format cjs,esm --dts --clean","prepublishOnly":"npm run build"},"_npmUser":{"name":"ace_won","email":"ace7coderr@gmail.com"},"repository":{"url":"git+https://github.com/ace-coderr/conduit.git","type":"git"},"_npmVersion":"10.9.2","description":"Drop-in x402 payment middleware for Next.js — powered by Conduit on Arc Network. Wrap any API route with one line to require USDC micropayments.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5","@types/node":"^20"},"peerDependencies":{"next":">=14.0.0","viem":">=2.0.0"},"peerDependenciesMeta":{"viem":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/x402_1.0.0_1779621776615_0.7584287176286304","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@ace_won/x402","version":"1.0.1","keywords":["x402","payment","middleware","nextjs","usdc","arc","arc-network","circle","micropayment","web3","eip-3009","conduit"],"author":{"name":"ace_won"},"license":"MIT","_id":"@ace_won/x402@1.0.1","maintainers":[{"name":"ace_won","email":"ace7coderr@gmail.com"}],"homepage":"https://conduit-pay.vercel.app/developers","bugs":{"url":"https://github.com/ace-coderr/conduit/issues"},"dist":{"shasum":"8199a62c06eb3ad08537e283745eaff33aee7972","tarball":"https://registry.npmjs.org/@ace_won/x402/-/x402-1.0.1.tgz","fileCount":6,"integrity":"sha512-1GiECZhye0opWubjrCygnHLexHaIhTxWcwqw4kloYhDJ5Tk/doWBx+LoHeeHlWjmG8L1HvtmRMOmUvINSSR20w==","signatures":[{"sig":"MEUCIQD7vhtdF+E2MiZnol8eVIM1yGwPJuElWxTkT1ZUv7ZLFgIgZDu4UrMt+rxDThQ3HjMNRtwCwGymehLEDCwXsUfYcn8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33855},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"d0388830c6aecacd78d8e0829519cade0d7a2665","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","build":"tsup src/index.ts --format cjs,esm --dts --clean","prepublishOnly":"npm run build"},"_npmUser":{"name":"ace_won","email":"ace7coderr@gmail.com"},"repository":{"url":"git+https://github.com/ace-coderr/conduit.git","type":"git"},"_npmVersion":"10.9.2","description":"Drop-in x402 payment middleware for Next.js — powered by Conduit on Arc Network. Wrap any API route with one line to require USDC micropayments.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5","@types/node":"^20"},"peerDependencies":{"next":">=14.0.0","viem":">=2.0.0"},"peerDependenciesMeta":{"viem":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/x402_1.0.1_1780054538654_0.028700512916276733","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@ace_won/x402","version":"1.0.2","description":"Drop-in x402 payment middleware for Next.js — powered by Conduit on Arc Network. Wrap any API route with one line to require USDC micropayments.","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","dev":"tsup src/index.ts --format cjs,esm --dts --watch","prepublishOnly":"npm run build"},"keywords":["x402","payment","middleware","nextjs","usdc","arc","arc-network","circle","micropayment","web3","eip-3009","conduit"],"author":{"name":"ace_won"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/ace-coderr/conduit.git"},"homepage":"https://conduit-pay.vercel.app/developers","bugs":{"url":"https://github.com/ace-coderr/conduit/issues"},"peerDependencies":{"next":">=14.0.0","viem":">=2.0.0"},"peerDependenciesMeta":{"viem":{"optional":true}},"devDependencies":{"@types/node":"^20","tsup":"^8.0.0","typescript":"^5"},"_id":"@ace_won/x402@1.0.2","gitHead":"8ad887408278e117223e2a2789bf5ce3fa1cf116","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-eNsAGsSaEVEJiGC/dHamVAa5sfuvvb1slJBht4pvrP3s9Yrg5lvDwrZpqwzpvlXiCuTVZvrUsTHdFb+gjnopqA==","shasum":"7f531087cfccd32ce473b009a56f20c3ccea0d50","tarball":"https://registry.npmjs.org/@ace_won/x402/-/x402-1.0.2.tgz","fileCount":6,"unpackedSize":34496,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGejE1Cw9e1+SE50JKfnZ/gnAtx9ezM8KHaPaXwH4F6qAiAFy0mH1ObT8YHf2MpoakBJ6SOY78xIbW7iq18qE41MYw=="}]},"_npmUser":{"name":"ace_won","email":"ace7coderr@gmail.com"},"directories":{},"maintainers":[{"name":"ace_won","email":"ace7coderr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/x402_1.0.2_1780087912462_0.4362029732100803"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-24T11:22:56.477Z","modified":"2026-05-29T20:51:52.738Z","1.0.0":"2026-05-24T11:22:56.752Z","1.0.1":"2026-05-29T11:35:38.807Z","1.0.2":"2026-05-29T20:51:52.652Z"},"bugs":{"url":"https://github.com/ace-coderr/conduit/issues"},"author":{"name":"ace_won"},"license":"MIT","homepage":"https://conduit-pay.vercel.app/developers","keywords":["x402","payment","middleware","nextjs","usdc","arc","arc-network","circle","micropayment","web3","eip-3009","conduit"],"repository":{"type":"git","url":"git+https://github.com/ace-coderr/conduit.git"},"description":"Drop-in x402 payment middleware for Next.js — powered by Conduit on Arc Network. Wrap any API route with one line to require USDC micropayments.","maintainers":[{"name":"ace_won","email":"ace7coderr@gmail.com"}],"readme":"# @ace_won/x402\r\n\r\n> Drop-in x402 payment middleware for Next.js — powered by Conduit on Arc Network.\r\n\r\nWrap any API route with **one line** to require USDC micropayments. No accounts, no API keys, no subscriptions. Humans pay via MetaMask, AI agents pay automatically via EIP-3009.\r\n\r\nBuilt on **Arc Network** · Powered by **Circle USDC** · Facilitated by **[Conduit](https://conduitpay.xyz)**\r\n\r\n---\r\n\r\n## Install\r\n\r\n```bash\r\nnpm install @ace_won/x402\r\n```\r\n\r\n---\r\n\r\n## Usage\r\n\r\n```ts\r\n// app/api/your-endpoint/route.ts\r\nimport { withPayment } from \"@ace_won/x402\";\r\nimport { NextRequest, NextResponse } from \"next/server\";\r\n\r\nasync function handler(req: NextRequest) {\r\n  return NextResponse.json({ data: \"your content here\" });\r\n}\r\n\r\n// Requires 0.001 USDC to access\r\nexport const GET = withPayment({ amount: \"0.001\" }, handler);\r\n```\r\n\r\nYour route now:\r\n\r\n- Returns `402 Payment Required` to unpaid requests\r\n- Shows a MetaMask pay page to browsers\r\n- Returns raw 402 JSON to AI agents\r\n- Verifies payment on-chain before serving the response\r\n- Settles asynchronously via Conduit's facilitator on Arc\r\n\r\n---\r\n\r\n## Options\r\n\r\n```ts\r\nwithPayment({\r\n  // Required\r\n  amount: \"0.001\",          // USDC amount — e.g. \"0.001\", \"0.01\", \"1.00\"\r\n\r\n  // Optional — all have sensible defaults\r\n  payTo: \"0xYourWallet\",    // Who receives payment. Defaults to Conduit fee collector\r\n  description: \"...\",       // Shown in 402 response and pay page\r\n  resource: \"https://...\",  // URL of this resource for tracking\r\n  facilitatorUrl: \"...\",    // Custom facilitator. Defaults to Conduit's\r\n  network: \"eip155:5042002\",// CAIP-2 network. Defaults to Arc Testnet\r\n  asset: \"0x3600...\",       // USDC contract. Defaults to Arc Testnet USDC\r\n  rpcUrl: \"https://rpc.testnet.arc.network\", // RPC for tx verification\r\n  maxTimeoutSeconds: 300,   // Max payment age in seconds. Defaults to 300\r\n}, handler);\r\n```\r\n\r\n---\r\n\r\n## How it works\r\n\r\n### For browsers (humans)\r\n\r\n1. Browser hits your route → gets a pay page at `conduitpay.xyz/pay/...`\r\n2. User connects wallet, confirms USDC transfer\r\n3. Browser retries with `PAYMENT-SIGNATURE: tx:<txHash>`\r\n4. Middleware verifies the tx on Arc\r\n5. Handler is called, response served\r\n\r\n### For AI agents\r\n\r\n1. Agent hits your route → gets `402` with payment details in `PAYMENT-REQUIRED` header\r\n2. Agent signs an EIP-3009 USDC authorization on Arc\r\n3. Agent retries with `PAYMENT-SIGNATURE: <base64 payload>`\r\n4. Middleware calls Conduit's `/api/x402/verify` endpoint\r\n5. Handler is called, response served\r\n6. Middleware calls `/api/x402/settle` async — USDC transferred on-chain\r\n\r\n---\r\n\r\n## Live demo\r\n\r\nHit this endpoint in your browser or with curl:\r\n\r\n```bash\r\ncurl -i https://conduitpay.xyz/api/arc-stats\r\n```\r\n\r\nYou'll get a `402 Payment Required` response with payment details. Pay 0.001 USDC, get live Arc Network stats back in under a second.\r\n\r\n---\r\n\r\n## List on the Marketplace\r\n\r\nOnce your x402 endpoint is live, list it on the [Conduit Marketplace](https://conduitpay.xyz/marketplace) so AI agents and developers can discover and pay for it automatically.\r\n\r\nSubmit at: **<https://conduitpay.xyz/marketplace/submit>**\r\n\r\n---\r\n\r\n## Multiple routes\r\n\r\n```ts\r\n// Basic data — 0.001 USDC\r\nexport const GET = withPayment({ amount: \"0.001\", description: \"Basic data\" }, basicHandler);\r\n\r\n// Premium analytics — 0.01 USDC, pay directly to your wallet\r\nexport const GET = withPayment({\r\n  amount: \"0.01\",\r\n  payTo: \"0xYourWallet\",\r\n  description: \"Premium analytics\",\r\n}, premiumHandler);\r\n\r\n// AI inference — pay per request\r\nexport const POST = withPayment({\r\n  amount: \"0.005\",\r\n  description: \"AI inference — pay per request\",\r\n}, inferenceHandler);\r\n```\r\n\r\n---\r\n\r\n## Network details\r\n\r\n| Property | Value |\r\n|----------|-------|\r\n| Network | Arc Testnet |\r\n| Chain ID | `5042002` |\r\n| CAIP-2 | `eip155:5042002` |\r\n| RPC URL | `https://rpc.testnet.arc.network` |\r\n| USDC | `0x3600000000000000000000000000000000000000` |\r\n| Facilitator | `https://conduitpay.xyz/api/x402` |\r\n| Explorer | `https://testnet.arcscan.app` |\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- Next.js 14+\r\n- `viem` v2+ (peer dependency)\r\n\r\n---\r\n\r\n## Links\r\n\r\n- **Live app:** <https://conduitpay.xyz>\r\n- **Developer docs:** <https://conduitpay.xyz/developers>\r\n- **API Marketplace:** <https://conduitpay.xyz/marketplace>\r\n- **GitHub:** <https://github.com/ace-coderr/conduit>\r\n- **Twitter:** [@conduit_pay](https://x.com/conduit_pay)\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT\r\n","readmeFilename":"README.md"}