Skip to content

Add a TypeScript client example that runs against a real deployed x402 endpoint#235

Open
StelarDigital wants to merge 2 commits into
coinbase:mainfrom
StelarDigital:docs/live-api-buyer-client-example
Open

Add a TypeScript client example that runs against a real deployed x402 endpoint#235
StelarDigital wants to merge 2 commits into
coinbase:mainfrom
StelarDigital:docs/live-api-buyer-client-example

Conversation

@StelarDigital

@StelarDigital StelarDigital commented Jul 7, 2026

Copy link
Copy Markdown

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, exact scheme) instead of spinning up a localhost demo server.

Why

Every existing TypeScript client example (fetch/, axios/, custom/, advanced/) targets http://localhost:4021 against 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 real PAYMENT-RESPONSE receipt. This example fills that gap: it's bring-your-own-endpoint - point RESOURCE_URL at 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-local ships 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

  • Structurally this mirrors clients/fetch/, scoped down to a single ExactEvmScheme registration since the illustrative endpoint only advertises the exact scheme on eip155:8453 (no SVM needed, keeps the example minimal).
  • Verified: lint (eslint . --ext .ts) and prettier --check pass. 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).
  • Was not able to fully build/typecheck the whole workspace locally (pnpm build at the typescript/ root) - the DTS generation step for @x402/core and @x402/evm OOMs on the available build memory. eslint, prettier, and a --no-dts JS-only build all succeeded, and the compiled example was run live as described above, but a full tsc --noEmit against the built .d.ts output wasn't possible in this environment. Happy to have CI double check or to rerun with more memory if that's a concern.
  • Majority of this PR (code + docs) was written with AI assistance (Claude), reviewed and tested against a live endpoint before opening this as ready for review. Flagging per the AI-assisted contribution guidance in CONTRIBUTING.md.
  • Open to feedback on the framing - happy to adjust the illustrative default endpoint, generalize further, or fold this into an existing example directory if that's preferred over a new one.

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.
@cb-heimdall

Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

Point readers to Coinbase Bazaar to discover live x402 endpoints to
try, rather than centering on one illustrative default URL. No
functional changes.
@StelarDigital StelarDigital changed the title Add a client example that calls a live/production x402 API Add a TypeScript client example that runs against a real deployed x402 endpoint Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants