Skip to content

Add x402 paid quote and withdrawal guide - #666

Open
ahhda wants to merge 1 commit into
mainfrom
codex/x402-integration-guide
Open

ahhda wants to merge 1 commit into
mainfrom
codex/x402-integration-guide

Conversation

@ahhda

@ahhda ahhda commented Oct 7, 2026 •

Copy link
Copy Markdown

Description

Add a public guide for obtaining paid quotes through x402 and withdrawing unused prepaid funds. Readers can inspect current terms without a key, then run a Base USDC example with optional spending and withdrawal-delay limits.

Changes

  • Keep the main flow on one page: get a quote, withdraw unused funds, and find other payment options or help.
  • Add downloadable quote, terms-preview and withdrawal examples. Expandable code blocks display those same files.
  • Preserve SDK receipt validation, payment limits, saved channel state and recovery guidance. Explain that the example's defaults are client limits and actual terms come from the service.
  • Link from the API and integration pages, and use the production API reference for protocol details.

Validation

  • yarn build and yarn typecheck pass; build includes strict link and anchor checks.
  • Quote and withdrawal examples compile against SDK 2.26.0.
  • 19 local checks cover default limits, overrides and rejected payment terms; no payments were signed or sent.
  • Reviewed the rendered page and confirmed all three downloads return the exact example source.

Summary by CodeRabbit

  • Documentation
    • Added a guide to using prepaid x402 payments for CoW Protocol quote requests without an API key, including funding, quote requests, and withdrawing unused funds.
    • Added runnable examples for inspecting payment terms, requesting quotes, and managing withdrawals.
    • Updated the integration overview and API guidance to include x402 as a payment option.

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Oct 7, 2026 3:58pm UTC

Request Review

@ahhda
ahhda requested a review from a team as a code owner October 7, 2026 15:56
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4430537d-11f6-4061-96eb-61401870df69
📥 Commits

Reviewing files that changed from the base of the PR and between 3df4739 and aca5789.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (8)
  • docs/cow-protocol/integrate/README.mdx
  • docs/cow-protocol/integrate/api.mdx
  • docs/cow-protocol/integrate/x402.mdx
  • package.json
  • static/code-examples/x402/inspect.mjs
  • static/code-examples/x402/quote.mts
  • static/code-examples/x402/withdraw.mts
  • tsconfig.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds x402 integration guidance and Node.js examples for inspecting payment terms, requesting paid quotes with saved recovery state, and checking or withdrawing unused channel funds.

Changes

x402 integration

Layer / File(s) Summary
Integration overview and terms preview
docs/cow-protocol/integrate/README.mdx, docs/cow-protocol/integrate/api.mdx, docs/cow-protocol/integrate/x402.mdx, static/code-examples/x402/inspect.mjs
Lists x402 as an integration option, links to its guide, and describes prepaid quotes and a read-only terms preview. The inspection script checks the payment challenge and displays the selected Base USDC terms.
Paid quote setup and request
docs/cow-protocol/integrate/x402.mdx, static/code-examples/x402/quote.mts, package.json, tsconfig.json
Documents client limits, quote requests, saved state, and recovery. The example validates payment requirements, saves signed attempts and channel configuration, submits a paid quote request, and reports the receipt and quote.
Channel withdrawal workflow
docs/cow-protocol/integrate/x402.mdx, static/code-examples/x402/withdraw.mts
Documents channel status checks, withdrawal initiation, and finalization. The script reads channel state and submits eligible withdrawal transactions.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Suggested reviewers: fleupold

Merge Risk: ⚪ Minimal · up to aca57

The guide and examples have no identified issue requiring correction before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (5 skipped: 5 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description includes the required Description and Changes sections. It clearly explains the x402 guide, examples, integrations, validation, and test results.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding an x402 paid quote and withdrawal guide.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (5 skipped: 5 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ahhda

ahhda commented Oct 7, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedraw-loader@​4.0.2991009975100

View full report

@ahhda

ahhda commented Oct 7, 2026

Copy link
Copy Markdown
Author

recheck

@@ -0,0 +1,127 @@
import { randomUUID } from "node:crypto";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example can be a little bit initimidating on the front page of the docs - do we need all this code for x402 quote to work?

This branch was successfully deployed

1 active deployment
Preview — aca5789d Deployed Oct 7, 2026 by vercel[bot]
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.

2 participants