Add a TypeScript client example that runs against a real deployed x402 endpoint#235
Open
StelarDigital wants to merge 2 commits into
Open
Add a TypeScript client example that runs against a real deployed x402 endpoint#235StelarDigital wants to merge 2 commits into
StelarDigital wants to merge 2 commits into
Conversation
Adds a client example that calls a real, production x402-protected endpoint instead of a localhost demo server, so the 402 -> pay -> 200 flow (PAYMENT-REQUIRED -> sign -> PAYMENT-SIGNATURE -> settle) can be observed end to end against live infrastructure on Base mainnet. Mirrors the fetch/ example pattern but scoped to a single EVM exact scheme, since the demo target only advertises that requirement.
🟡 Heimdall Review Status
|
Point readers to Coinbase Bazaar to discover live x402 endpoints to try, rather than centering on one illustrative default URL. No functional changes.
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.
What
Adds
examples/typescript/clients/live-api-buyer/, a small@x402/fetch-based client example that calls a real, already-deployed x402 endpoint (Base mainnet,exactscheme) instead of spinning up a localhost demo server.Why
Every existing TypeScript client example (
fetch/,axios/,custom/,advanced/) targetshttp://localhost:4021against a demo server started for the walkthrough. That's the right default for most examples, but it means a reader never actually sees the 402 -> pay -> 200 flow resolve against real infrastructure - real facilitator verification, real settlement, a realPAYMENT-RESPONSEreceipt. This example fills that gap: it's bring-your-own-endpoint - pointRESOURCE_URLat any live x402-protected URL and it runs the exact same flow the other examples demonstrate, just against something that's actually deployed. The README points readers to Coinbase Bazaar to discover live endpoints to try..env-localships with one illustrative default (https://api.stelardigital.com/pricecheck) purely as a working example URL to run against out of the box - any live x402 endpoint works identically.Notes for reviewers
clients/fetch/, scoped down to a singleExactEvmSchemeregistration since the illustrative endpoint only advertises theexactscheme oneip155:8453(no SVM needed, keeps the example minimal).eslint . --ext .ts) andprettier --checkpass. Also ran the client against the live default endpoint with an unfunded throwaway wallet to confirm the full request -> 402 -> decode -> sign -> retry flow executes correctly end-to-end (it correctly reaches the facilitator's verify step and fails only on insufficient balance, as expected for an unfunded test key).pnpm buildat thetypescript/root) - the DTS generation step for@x402/coreand@x402/evmOOMs on the available build memory.eslint,prettier, and a--no-dtsJS-only build all succeeded, and the compiled example was run live as described above, but a fulltsc --noEmitagainst the built.d.tsoutput wasn't possible in this environment. Happy to have CI double check or to rerun with more memory if that's a concern.