Add x402 payment protocol support#27
Merged
Merged
Conversation
29db020 to
5c9a72f
Compare
5c9a72f to
47fe838
Compare
0137feb to
9cfd75d
Compare
Shedna
requested changes
Mar 18, 2026
| @@ -0,0 +1,3 @@ | |||
| export interface X402Signer { | |||
| createPaymentPayload(paymentRequired: unknown): Promise<unknown>; | |||
Contributor
There was a problem hiding this comment.
unknown -> Promise. Can't we do better here or not ?
Contributor
Author
There was a problem hiding this comment.
We can't type this better without changing the project's moduleResolution.
With "node", TypeScript can't resolve @x402/core subpath exports (@x402/core/types), so we can't import PaymentRequired / PaymentPayload directly. Keeping unknown for now — we'll type it properly when we migrate to moduleResolution: "node16" or "bundler
| "@commitlint/config-conventional": "^19.8.1", | ||
| "@types/jest": "^29.5.14", | ||
| "@types/node": "^24.0.4", | ||
| "@x402/evm": "^2.7.0", |
Contributor
There was a problem hiding this comment.
I think you missed @x402/core also in devDependencies no ?
Shedna
reviewed
Mar 18, 2026
Shedna
approved these changes
Mar 19, 2026
Contributor
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
automatically handle HTTP 402 responses by signing and retrying requests with on-chain
payments
X402Signerabstraction andcreateX402Signerhelper that wires up viem +@x402/evm+@x402/corefor Base chain EVM paymentsLinkupPaymentRequiredErrorfor cases where a 402 is received but cannot behandled (e.g. missing header, already retried)
signs payment payloads, and retries the original request
Test plan
createX402Signer(account creation, public client setup, EVMsigner wiring, chain registration, payload delegation, error propagation) — 100% coverage
header, already-retried guard, non-402 passthrough, network errors)
LinkupPaymentRequiredErrorUsage