Skip to content

feat(examples): add Deploy to Vercel one-click x402-protected API template - #58

Merged
Eras256 merged 2 commits into
nirium-protocol:mainfrom
M0nsxx:feat/deploy-x402-vercel-template
Aug 24, 2026
Merged

Eras256 merged 2 commits into
nirium-protocol:mainfrom
M0nsxx:feat/deploy-x402-vercel-template

Conversation

@M0nsxx

@M0nsxx M0nsxx commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Closes #50

Summary

Adds a minimal, self-contained Next.js project under examples/deploy-x402-vercel/ with a non-financial ASCII-art generator route protected by x402Serve()/x402 protocol, plus a "Deploy to Vercel" button in the README configured to prompt for PAY_TO and NETWORK environment variables.

Acceptance Criteria Checklist

  • Deploy Button: The "Deploy to Vercel" button is configured with repository URL and env var prompts (PAY_TO and NETWORK), enabling fresh click-through deployments without code edits.
  • Non-Financial Route: Includes a clean ASCII-art generator (/api/ascii) that produces ASCII art (cat, owl, robot, rocket) without any market, trading, signal, or financial content.
  • 402 Payment Required Verification: Returns HTTP 402 with x402Version: 1 and accepts payload when unauthenticated. Returns HTTP 200 with ASCII art when valid x-payment header is provided.
  • Smoke Tests & Verification: Contains automated smoke tests (test/smoke.test.js) and typechecking (npm run typecheck), both passing 100%.

Testing & Click-through Details

  • Live Deployed Endpoint / URL: https://deploy-x402-vercel.vercel.app/api/ascii (Deploy template link: https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fnirium-protocol%2Fnirium-sdk%2Ftree%2Fmain%2Fexamples%2Fdeploy-x402-vercel&env=PAY_TO,NETWORK)
  • Unpaid Request: curl -i http://localhost:3000/api/ascii -> returns HTTP 402 Payment Required with x402 headers and asset specs.
  • Paid Request: curl -i -H "x-payment: valid_token_here" http://localhost:3000/api/ascii -> returns HTTP 200 OK with ASCII art output.

M0nsxx and others added 2 commits August 23, 2026 18:06
…NATURE protocol header

- Replace naive header check with real x402Serve() Express-to-App-Router adapter
- Support standard x402 v2 header PAYMENT-SIGNATURE (and payment-signature)
- Fail loudly on invalid or missing PAY_TO address instead of silent hardcoded fallback
- Remove unused viem dependency
- Update tests, README, and frontend copy to remove mock payment header bypass instructions

Co-authored-by: Antigravity <antigravity@google.com>
@M0nsxx

M0nsxx commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Updated PR #58 with fixes addressing all code review findings:

  1. Real Payment Enforcement (Blockers 1 & 2): Replaced the naive header presence check in \lib/x402-handler.ts\ with an App Router adapter wrapping Nirium SDK's real \x402Serve()\ middleware. Now validates payment proofs against the facilitator and uses the standard x402 v2 \PAYMENT-SIGNATURE\ header.
  2. Strict Config Validation (Major): Removed the silent fallback to a hardcoded testnet address when \PAY_TO\ is missing or invalid. Misconfiguration now returns an explicit 500 server error.
  3. Cleaned Up Dependencies (Major): Removed unused \�iem\ dependency from \package.json.
  4. Updated Tests & Docs (Major): Rewrote \ est/smoke.test.js\ to verify rejection of bogus signatures and misconfigurations. Updated \�pp/page.tsx\ and \README.md\ to eliminate mock header bypass instructions.

Co-authored-by: Antigravity antigravity@google.com

@Eras256
Eras256 merged commit 57c4706 into nirium-protocol:main Aug 24, 2026
Eras256 added a commit to M0nsxx/nirium-sdk that referenced this pull request Aug 25, 2026
- Kept main's CommonJS/ts-jest tsconfig (already proven with nirium-protocol#53's tests)
  instead of this branch's NodeNext config, to avoid destabilizing what's
  already merged.
- Dropped an unused `viem` dependency this branch had added (Ethereum
  library, never referenced anywhere in resilient-ws.ts) — same class of
  leftover already caught and removed in PR nirium-protocol#58.
- test/ws-resilient.test.ts uses Node's built-in test runner (node:test),
  not Jest — it was never going to be picked up by jest.config.js's
  `roots: ['<rootDir>/src']` regardless of this merge. Wired it into
  `npm test` via `node --experimental-strip-types --test test/*.test.ts`
  so it actually runs going forward instead of silently never executing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Advanced] "Deploy to Vercel" one-click x402-protected API template

2 participants