From c357d901c8c55199cc18e0b471137376948170e0 Mon Sep 17 00:00:00 2001 From: Gilberts Ahumada Date: Mon, 20 Oct 2025 22:33:45 -0400 Subject: [PATCH 1/2] fix: update quickstart guide to include signer instantiation for x402-fetch --- getting-started/quickstart-for-buyers.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/getting-started/quickstart-for-buyers.md b/getting-started/quickstart-for-buyers.md index 841625f..12b9cc5 100644 --- a/getting-started/quickstart-for-buyers.md +++ b/getting-started/quickstart-for-buyers.md @@ -52,7 +52,19 @@ pip install x402 #### Create a Wallet Client {% tabs %} -{% tab title="Node.js (viem)" %} +{% tab title="Node.js - Fetch " %} + +Instantiate the signer: + +```typescript +import { createSigner } from "x402-fetch"; + +// Create a signer (using your private key) +const signer = await createSigner("base-sepolia", "0xYourPrivateKey"); // we recommend using an environment variable for this +``` +{% endtab %} + +{% tab title="Node.js - Axios (viem)" %} Install the required package: ```bash @@ -113,12 +125,12 @@ You can use either `x402-fetch` or `x402-axios` to automatically handle 402 Paym **x402-fetch** extends the native `fetch` API to handle 402 responses and payment headers for you. [Full example here](https://github.com/coinbase/x402/tree/main/examples/typescript/clients/fetch) ```typescript -import { wrapFetchWithPayment, decodeXPaymentResponse } from "x402-fetch"; +import { wrapFetchWithPayment, decodeXPaymentResponse, createSigner } from "x402-fetch"; // other imports... // wallet creation logic... -const fetchWithPayment = wrapFetchWithPayment(fetch, account); +const fetchWithPayment = wrapFetchWithPayment(fetch, signer); fetchWithPayment(url, { //url should be something like https://api.example.com/paid-endpoint method: "GET", From 03dfc5570b7ad30c351aad73a50a5b2f6307397e Mon Sep 17 00:00:00 2001 From: Gilberts Ahumada Date: Mon, 20 Oct 2025 22:37:26 -0400 Subject: [PATCH 2/2] comment updated --- getting-started/quickstart-for-buyers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getting-started/quickstart-for-buyers.md b/getting-started/quickstart-for-buyers.md index 12b9cc5..184782f 100644 --- a/getting-started/quickstart-for-buyers.md +++ b/getting-started/quickstart-for-buyers.md @@ -128,7 +128,7 @@ You can use either `x402-fetch` or `x402-axios` to automatically handle 402 Paym import { wrapFetchWithPayment, decodeXPaymentResponse, createSigner } from "x402-fetch"; // other imports... -// wallet creation logic... +// signer creation logic... const fetchWithPayment = wrapFetchWithPayment(fetch, signer);