You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Expected outcome:** Project directory created with x402 fetch client dependencies installed.
37
+
</Check>
38
+
</Step>
39
+
40
+
<Steptitle="Environment Configuration">
41
+
Create a `.env` file in your project root:
42
+
43
+
```env
44
+
# Required: Your private key for making payments
45
+
PRIVATE_KEY=0xYourPrivateKeyHere
46
+
47
+
# Required: The server URL hosting the paid API
48
+
RESOURCE_SERVER_URL=http://localhost:4021
49
+
50
+
# Required: The endpoint path to access
51
+
ENDPOINT_PATH=/weather
52
+
```
53
+
54
+
<Warning>
55
+
**Security Note**: Never commit private keys to version control. Use environment variables or secure key management services in production. For testing, you can use a dummy private key.
56
+
</Warning>
57
+
58
+
<Check>
59
+
**Expected outcome:** Environment variables configured for your fetch client.
60
+
</Check>
61
+
</Step>
62
+
63
+
<Steptitle="Create the fetch client">
64
+
Create `fetch-client.ts` with the payment-enabled fetch implementation:
**Expected outcome:** Fetch client code created with automatic payment handling.
114
+
</Check>
115
+
</Step>
116
+
117
+
<Steptitle="Run your fetch client">
118
+
Execute your fetch client to make paid requests:
119
+
120
+
<CodeGroup>
121
+
```bash pnpm
122
+
pnpx tsx fetch-client.ts
123
+
```
124
+
125
+
```bash yarn
126
+
yarn tsx fetch-client.ts
127
+
```
128
+
129
+
```bash npm
130
+
npx tsx fetch-client.ts
131
+
```
132
+
133
+
```bash direct
134
+
npx tsx fetch-client.ts
135
+
```
136
+
</CodeGroup>
137
+
138
+
<Check>
139
+
**Expected outcome:** The client should automatically handle the 402 Payment Required response, make the payment, and receive the protected content.
140
+
</Check>
141
+
142
+
<Info>
143
+
Make sure your paid API server is running on the configured URL. The fetch client will automatically detect 402 responses, handle payment processing, and retry the request with payment proof.
0 commit comments