@dexterai/x402 1.7.2 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -6
- package/dist/adapters/index.cjs +419 -412
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +11 -5
- package/dist/adapters/index.d.ts +11 -5
- package/dist/adapters/index.js +395 -415
- package/dist/adapters/index.js.map +1 -1
- package/dist/client/index.cjs +585 -566
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +6 -6
- package/dist/client/index.d.ts +6 -6
- package/dist/client/index.js +595 -572
- package/dist/client/index.js.map +1 -1
- package/dist/react/index.cjs +415 -416
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +410 -413
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.cjs +220 -94
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +53 -36
- package/dist/server/index.d.ts +53 -36
- package/dist/server/index.js +220 -94
- package/dist/server/index.js.map +1 -1
- package/dist/{solana-BWNn6iue.d.cts → solana-BeGAqPta.d.cts} +16 -4
- package/dist/{solana-q6Na2BF-.d.ts → solana-CQD9yMju.d.ts} +16 -4
- package/dist/{types-BzL-q-AE.d.cts → types-B477nBpg.d.cts} +7 -2
- package/dist/{types-By5Hhdmr.d.ts → types-BWnUAPvD.d.ts} +7 -2
- package/dist/{x402-client-rG7xFxSR.d.ts → x402-client-D9b3PHai.d.ts} +23 -2
- package/dist/{x402-client-BvQfgGwD.d.cts → x402-client-Dk9q2QQF.d.cts} +23 -2
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Quality-verified endpoints (score 75+) get promoted in search results. The verif
|
|
|
70
70
|
npm install @dexterai/x402
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
### Client (Node.js)
|
|
73
|
+
### Client (Node.js)
|
|
74
74
|
|
|
75
75
|
The simplest way to make x402 payments from scripts:
|
|
76
76
|
|
|
@@ -85,6 +85,20 @@ const x402Fetch = wrapFetch(fetch, {
|
|
|
85
85
|
const response = await x402Fetch('https://api.example.com/protected');
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
Check the payment receipt:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { wrapFetch, getPaymentReceipt } from '@dexterai/x402/client';
|
|
92
|
+
|
|
93
|
+
const x402Fetch = wrapFetch(fetch, { walletPrivateKey: process.env.SOLANA_PRIVATE_KEY });
|
|
94
|
+
const response = await x402Fetch('https://api.example.com/protected');
|
|
95
|
+
|
|
96
|
+
const receipt = getPaymentReceipt(response);
|
|
97
|
+
if (receipt) {
|
|
98
|
+
console.log('Paid:', receipt.transaction, 'on', receipt.network);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
88
102
|
### Client (Browser)
|
|
89
103
|
|
|
90
104
|
```typescript
|
|
@@ -152,12 +166,48 @@ function PayButton() {
|
|
|
152
166
|
|
|
153
167
|
## Supported Networks
|
|
154
168
|
|
|
155
|
-
|
|
156
|
-
|---------|------------|--------|--------|
|
|
157
|
-
| Solana Mainnet | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | ✅ Verified | ✅ Verified |
|
|
158
|
-
| Base Mainnet | `eip155:8453` | ✅ Verified | ✅ Verified |
|
|
169
|
+
All networks supported by the [Dexter facilitator](https://x402.dexter.cash/supported). USDC on every chain.
|
|
159
170
|
|
|
160
|
-
|
|
171
|
+
**Mainnets:**
|
|
172
|
+
|
|
173
|
+
| Network | CAIP-2 | Status |
|
|
174
|
+
|---------|--------|--------|
|
|
175
|
+
| Solana | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | Production |
|
|
176
|
+
| Base | `eip155:8453` | Production |
|
|
177
|
+
| Polygon | `eip155:137` | Production |
|
|
178
|
+
| Arbitrum | `eip155:42161` | Production |
|
|
179
|
+
| Optimism | `eip155:10` | Production |
|
|
180
|
+
| Avalanche | `eip155:43114` | Production |
|
|
181
|
+
| SKALE Base | `eip155:1187947933` | Production (zero gas) |
|
|
182
|
+
|
|
183
|
+
**Testnets:**
|
|
184
|
+
|
|
185
|
+
| Network | CAIP-2 |
|
|
186
|
+
|---------|--------|
|
|
187
|
+
| Solana Devnet | `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1` |
|
|
188
|
+
| Base Sepolia | `eip155:84532` |
|
|
189
|
+
| SKALE Sepolia | `eip155:324705682` |
|
|
190
|
+
|
|
191
|
+
Accept payments on multiple chains simultaneously:
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
// Same address across EVM chains
|
|
195
|
+
app.get('/api/data', x402Middleware({
|
|
196
|
+
payTo: '0xYourAddress',
|
|
197
|
+
amount: '0.01',
|
|
198
|
+
network: ['eip155:8453', 'eip155:137', 'eip155:42161', 'eip155:10'],
|
|
199
|
+
}));
|
|
200
|
+
|
|
201
|
+
// Different addresses per chain family
|
|
202
|
+
app.get('/api/data', x402Middleware({
|
|
203
|
+
payTo: {
|
|
204
|
+
'solana:*': 'YourSolanaAddress...',
|
|
205
|
+
'eip155:*': '0xYourEvmAddress...',
|
|
206
|
+
},
|
|
207
|
+
amount: '0.01',
|
|
208
|
+
network: ['solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', 'eip155:8453', 'eip155:137'],
|
|
209
|
+
}));
|
|
210
|
+
```
|
|
161
211
|
|
|
162
212
|
---
|
|
163
213
|
|
|
@@ -530,6 +580,23 @@ tiktoken's default encoding works well for most transformer models. Only use a c
|
|
|
530
580
|
|
|
531
581
|
---
|
|
532
582
|
|
|
583
|
+
## Sponsored Access (v1.7.2)
|
|
584
|
+
|
|
585
|
+
**Server middleware** accepts `sponsoredAccess: true` in its config. When enabled, it reads `extensions["sponsored-access"]` from the facilitator's settlement response and injects `_x402_sponsored` into the JSON response body so agents can see recommendations.
|
|
586
|
+
|
|
587
|
+
```typescript
|
|
588
|
+
app.use(x402Middleware({
|
|
589
|
+
facilitatorUrl: "https://x402.dexter.cash",
|
|
590
|
+
sponsoredAccess: true, // opt-in to recommendation injection
|
|
591
|
+
}));
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
**Client SDK** decodes the `PAYMENT-RESPONSE` header from x402 responses and attaches the full settlement receipt (including extensions) as `response._x402` for programmatic access.
|
|
595
|
+
|
|
596
|
+
**Types:** `SettleResponse` now includes an optional `extensions` field.
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
533
600
|
## API Reference
|
|
534
601
|
|
|
535
602
|
### `createX402Client(options)`
|