Implement x402curl to print JavaScript code for x402-client#15
Merged
Conversation
The tool prints JavaScript code that: - Uses x402-client library to handle HTTP 402 payments - Loads wallet from ~/.payment/wallet.json and password from ~/.payment/password.txt - Accepts payment_url as command line argument - Supports --max-payment option for payment limits Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wrap the JavaScript code with clear instructions explaining: - How to save and run the code - The npm package dependency requirement Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces the x402curl CLI tool, which prints a ready-to-run JavaScript example that uses the x402-client library to complete HTTP 402 payment flows.
Changes:
- Add a
clap-based argument parser forpayment_urland an optional--max-paymentflag. - Implement
generate_codeto produce a Node.js ESM script that reads the wallet and password from~/.payment, initializesx402-client, and performs afetchWithPaymentto the provided URL. - Wire up the new
x402curlbinary in its own crate with the necessaryclapdependency inCargo.toml.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| x402curl/src/main.rs | Defines CLI arguments and generates the JavaScript snippet that uses x402-client with optional maxPayment. |
| x402curl/Cargo.toml | Registers the x402curl binary crate and adds clap as a dependency, consistent with other workspace tools. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement the x402curl tool to print JavaScript code that uses the x402-client library.
The generated code:
x402-clientlibrary to handle HTTP 402 payments~/.payment/wallet.jsonand password from~/.payment/password.txtpayment_urlas a command line argument--max-paymentoption for payment limitsUsage
Test plan
cargo build --releasesucceedscargo test --allpasses🤖 Generated with Claude Code