@dexterai/x402 1.9.3 → 2.0.0

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.
Files changed (39) hide show
  1. package/dist/adapters/index.cjs +14 -6
  2. package/dist/adapters/index.d.cts +3 -5
  3. package/dist/adapters/index.d.ts +3 -5
  4. package/dist/adapters/index.js +14 -6
  5. package/dist/client/index.cjs +251 -29
  6. package/dist/client/index.d.cts +215 -37
  7. package/dist/client/index.d.ts +215 -37
  8. package/dist/client/index.js +248 -29
  9. package/dist/react/index.cjs +88 -33
  10. package/dist/react/index.d.cts +10 -5
  11. package/dist/react/index.d.ts +10 -5
  12. package/dist/react/index.js +88 -33
  13. package/dist/server/index.cjs +27 -4
  14. package/dist/server/index.d.cts +45 -13
  15. package/dist/server/index.d.ts +45 -13
  16. package/dist/server/index.js +27 -4
  17. package/dist/{sponsored-access-H1EX6zpi.d.ts → sponsored-access-BgEDLg_H.d.cts} +31 -2
  18. package/dist/{sponsored-access-BCB2CxdG.d.cts → sponsored-access-DjLEKhOV.d.ts} +31 -2
  19. package/dist/{types-BQvaF8lB.d.cts → types-CjLMR7qs.d.cts} +1 -1
  20. package/dist/{types-BQvaF8lB.d.ts → types-CjLMR7qs.d.ts} +1 -1
  21. package/dist/types-D1TGACsL.d.ts +245 -0
  22. package/dist/types-DWhpiOBD.d.cts +245 -0
  23. package/dist/utils/index.cjs +8 -7
  24. package/dist/utils/index.js +8 -7
  25. package/package.json +1 -1
  26. package/dist/adapters/index.cjs.map +0 -1
  27. package/dist/adapters/index.js.map +0 -1
  28. package/dist/client/index.cjs.map +0 -1
  29. package/dist/client/index.js.map +0 -1
  30. package/dist/react/index.cjs.map +0 -1
  31. package/dist/react/index.js.map +0 -1
  32. package/dist/server/index.cjs.map +0 -1
  33. package/dist/server/index.js.map +0 -1
  34. package/dist/solana-CfHuiW2H.d.cts +0 -132
  35. package/dist/solana-kZcwbUK9.d.ts +0 -132
  36. package/dist/types-DmqH9yD8.d.cts +0 -123
  37. package/dist/types-ENcnkof8.d.ts +0 -123
  38. package/dist/utils/index.cjs.map +0 -1
  39. package/dist/utils/index.js.map +0 -1
@@ -1,32 +1,11 @@
1
- export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-BCB2CxdG.cjs';
2
- import { A as AccessPassClientConfig } from '../types-BQvaF8lB.cjs';
3
- export { b as AccessPassInfo, a as AccessPassTier, D as DEXTER_FACILITATOR_URL, U as USDC_MINT, X as X402Error } from '../types-BQvaF8lB.cjs';
4
- import { Transaction, VersionedTransaction, Keypair } from '@solana/web3.js';
5
- import { E as EvmWallet } from '../solana-CfHuiW2H.cjs';
6
- export { B as BASE_MAINNET, S as SOLANA_MAINNET, a as createEvmAdapter, c as createSolanaAdapter } from '../solana-CfHuiW2H.cjs';
7
- export { C as ChainAdapter, W as WalletSet } from '../types-DmqH9yD8.cjs';
1
+ export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-BgEDLg_H.cjs';
2
+ import { A as AccessPassClientConfig, P as PaymentAccept } from '../types-CjLMR7qs.cjs';
3
+ export { b as AccessPassInfo, a as AccessPassTier, D as DEXTER_FACILITATOR_URL, U as USDC_MINT, X as X402Error } from '../types-CjLMR7qs.cjs';
4
+ import { Keypair } from '@solana/web3.js';
5
+ import { S as SolanaWallet, E as EvmWallet } from '../types-DWhpiOBD.cjs';
6
+ export { B as BASE_MAINNET, C as ChainAdapter, b as SOLANA_MAINNET, W as WalletSet, a as createEvmAdapter, c as createSolanaAdapter } from '../types-DWhpiOBD.cjs';
8
7
  export { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
9
8
 
10
- /**
11
- * Simple Fetch Wrapper for Node.js
12
- *
13
- * The easiest way to make x402 payments from Node.js scripts.
14
- * Just provide a private key and it handles everything automatically.
15
- *
16
- * @example
17
- * ```typescript
18
- * import { wrapFetch } from '@dexterai/x402/client';
19
- *
20
- * const x402Fetch = wrapFetch(fetch, {
21
- * walletPrivateKey: process.env.SOLANA_PRIVATE_KEY!,
22
- * });
23
- *
24
- * // Make a paid request - payment happens automatically
25
- * const response = await x402Fetch('https://api.example.com/protected');
26
- * const data = await response.json();
27
- * ```
28
- */
29
-
30
9
  /**
31
10
  * Options for wrapFetch
32
11
  */
@@ -81,6 +60,11 @@ interface WrapFetchOptions {
81
60
  * ```
82
61
  */
83
62
  accessPass?: AccessPassClientConfig;
63
+ /**
64
+ * Called before signing a payment. Return true to proceed, false to reject.
65
+ * Used internally by Budget Accounts — can also be set directly.
66
+ */
67
+ onPaymentRequired?: (requirements: PaymentAccept) => boolean | Promise<boolean>;
84
68
  }
85
69
  /**
86
70
  * Wrap fetch with automatic x402 payment handling
@@ -135,19 +119,27 @@ declare function wrapFetch(fetchImpl: typeof globalThis.fetch, options: WrapFetc
135
119
  * ```
136
120
  */
137
121
 
122
+ /** Symbol key for the underlying Keypair — prevents accidental exposure via console.log or JSON.stringify */
123
+ declare const KEYPAIR_SYMBOL: unique symbol;
138
124
  /**
139
- * Keypair wallet interface (compatible with SDK's SolanaWallet)
125
+ * Keypair wallet interface extends SolanaWallet with safe Keypair access.
140
126
  */
141
- interface KeypairWallet {
142
- /** Public key with toBase58() method */
143
- publicKey: {
144
- toBase58(): string;
145
- };
146
- /** Sign a transaction */
147
- signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T>;
148
- /** Get the underlying keypair (for advanced use) */
127
+ interface KeypairWallet extends SolanaWallet {
128
+ /**
129
+ * Get the underlying Keypair. Accessed via Symbol to prevent accidental
130
+ * exposure through console.log, JSON.stringify, or Object.keys.
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * import { KEYPAIR_SYMBOL } from '@dexterai/x402/client';
135
+ * const kp = wallet[KEYPAIR_SYMBOL];
136
+ * ```
137
+ */
138
+ [KEYPAIR_SYMBOL]: Keypair;
139
+ /** @deprecated Use wallet[KEYPAIR_SYMBOL] instead — this will be removed in a future major version */
149
140
  keypair: Keypair;
150
141
  }
142
+
151
143
  /**
152
144
  * Create a wallet from a Solana private key
153
145
  *
@@ -245,4 +237,190 @@ declare function createEvmKeypairWallet(privateKey: string): Promise<EvmWallet>;
245
237
  */
246
238
  declare function isEvmKeypairWallet(wallet: unknown): wallet is EvmWallet;
247
239
 
248
- export { AccessPassClientConfig, type KeypairWallet, type WrapFetchOptions, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, wrapFetch };
240
+ /**
241
+ * API Discovery — Find x402 Paid APIs
242
+ *
243
+ * Search the Dexter marketplace for x402-enabled APIs. Discover endpoints
244
+ * by category, price range, network, and quality score — then pay for them
245
+ * with the same SDK.
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * import { searchAPIs } from '@dexterai/x402/client';
250
+ *
251
+ * const results = await searchAPIs({ query: 'sentiment analysis', maxPrice: 0.10 });
252
+ * for (const api of results) {
253
+ * console.log(`${api.name}: ${api.price} — ${api.description}`);
254
+ * }
255
+ *
256
+ * // Then call one with wrapFetch:
257
+ * const response = await x402Fetch(results[0].url);
258
+ * ```
259
+ */
260
+ /**
261
+ * Search options for discovering x402 APIs
262
+ */
263
+ interface SearchAPIsOptions {
264
+ /** Search query (e.g., 'sentiment analysis', 'token price', 'image generation') */
265
+ query?: string;
266
+ /** Filter by category (e.g., 'defi', 'ai', 'data', 'social') */
267
+ category?: string;
268
+ /** Filter by payment network (e.g., 'solana', 'base', 'polygon') */
269
+ network?: string;
270
+ /** Maximum price per call in USDC */
271
+ maxPrice?: number;
272
+ /** Only return verified endpoints (quality score 75+) */
273
+ verifiedOnly?: boolean;
274
+ /** Sort order */
275
+ sort?: 'marketplace' | 'relevance' | 'quality_score' | 'settlements' | 'volume' | 'recent';
276
+ /** Maximum results to return (default 20, max 50) */
277
+ limit?: number;
278
+ /** Marketplace API URL (default: Dexter marketplace) */
279
+ marketplaceUrl?: string;
280
+ }
281
+ /**
282
+ * A discovered x402 API endpoint
283
+ */
284
+ interface DiscoveredAPI {
285
+ /** API name */
286
+ name: string;
287
+ /** Full resource URL — pass directly to wrapFetch or createX402Client.fetch */
288
+ url: string;
289
+ /** HTTP method */
290
+ method: string;
291
+ /** Price per call (formatted, e.g., '$0.05') */
292
+ price: string;
293
+ /** Price per call in USDC (raw number, null if free) */
294
+ priceUsdc: number | null;
295
+ /** Payment network */
296
+ network: string | null;
297
+ /** Human-readable description */
298
+ description: string;
299
+ /** Category (e.g., 'defi', 'ai', 'data') */
300
+ category: string;
301
+ /** Quality score (0-100, null if unscored) */
302
+ qualityScore: number | null;
303
+ /** Whether the endpoint has been verified */
304
+ verified: boolean;
305
+ /** Total number of settlements (calls) */
306
+ totalCalls: number;
307
+ /** Total volume in USDC (formatted, e.g., '$1,234.56') */
308
+ totalVolume: string | null;
309
+ /** Seller name */
310
+ seller: string | null;
311
+ /** Seller reputation score */
312
+ sellerReputation: number | null;
313
+ /** Whether authentication is required beyond payment */
314
+ authRequired: boolean;
315
+ /** Last time someone called this API */
316
+ lastActive: string | null;
317
+ }
318
+ /**
319
+ * Search the Dexter marketplace for x402 paid APIs.
320
+ *
321
+ * Returns a list of discovered endpoints that can be called directly
322
+ * with `wrapFetch` or `createX402Client.fetch`.
323
+ *
324
+ * @example Find AI APIs under $0.10
325
+ * ```typescript
326
+ * const apis = await searchAPIs({ query: 'ai', maxPrice: 0.10 });
327
+ * ```
328
+ *
329
+ * @example Browse all verified DeFi tools
330
+ * ```typescript
331
+ * const apis = await searchAPIs({ category: 'defi', verifiedOnly: true });
332
+ * ```
333
+ *
334
+ * @example Find cheapest APIs on Solana
335
+ * ```typescript
336
+ * const apis = await searchAPIs({ network: 'solana', sort: 'quality_score' });
337
+ * ```
338
+ */
339
+ declare function searchAPIs(options?: SearchAPIsOptions): Promise<DiscoveredAPI[]>;
340
+
341
+ /**
342
+ * Budget Account — Autonomous Agent Spending Controls
343
+ *
344
+ * Wraps the x402 client with a spending limit, per-request cap,
345
+ * per-hour rate limit, and optional domain allowlist. Tracks cumulative
346
+ * spend and exposes remaining budget. When the budget is exhausted,
347
+ * requests throw instead of paying.
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * import { createBudgetAccount } from '@dexterai/x402/client';
352
+ *
353
+ * const agent = createBudgetAccount({
354
+ * walletPrivateKey: process.env.SOLANA_PRIVATE_KEY,
355
+ * budget: {
356
+ * total: '50.00', // $50 total budget
357
+ * perRequest: '1.00', // max $1 per request
358
+ * perHour: '10.00', // max $10/hour
359
+ * },
360
+ * allowedDomains: ['api.example.com', 'data.example.com'],
361
+ * });
362
+ *
363
+ * const response = await agent.fetch('https://api.example.com/data');
364
+ * console.log(agent.spent); // '$0.05'
365
+ * console.log(agent.remaining); // '$49.95'
366
+ * console.log(agent.payments); // 1
367
+ * ```
368
+ */
369
+
370
+ /** Budget configuration */
371
+ interface BudgetConfig {
372
+ /** Total spending limit in USD (e.g., '50.00') */
373
+ total: string;
374
+ /** Maximum amount per single request in USD (e.g., '1.00'). Optional. */
375
+ perRequest?: string;
376
+ /** Maximum spend per hour in USD (e.g., '10.00'). Optional. */
377
+ perHour?: string;
378
+ }
379
+ /** Budget Account configuration — extends WrapFetchOptions with spending controls */
380
+ interface BudgetAccountConfig extends WrapFetchOptions {
381
+ /** Spending limits */
382
+ budget: BudgetConfig;
383
+ /** Restrict payments to these domains only. If omitted, all domains allowed. */
384
+ allowedDomains?: string[];
385
+ }
386
+ /** A payment record in the spend ledger */
387
+ interface PaymentRecord {
388
+ /** Amount paid in USD */
389
+ amount: number;
390
+ /** Domain that was paid */
391
+ domain: string;
392
+ /** CAIP-2 network used */
393
+ network: string;
394
+ /** Timestamp (ms) */
395
+ timestamp: number;
396
+ }
397
+ /** Budget Account — fetch with spending controls */
398
+ interface BudgetAccount {
399
+ /** Payment-aware fetch with budget enforcement */
400
+ fetch: typeof globalThis.fetch;
401
+ /** Total amount spent (formatted, e.g., '$12.34') */
402
+ readonly spent: string;
403
+ /** Remaining budget (formatted, e.g., '$37.66') */
404
+ readonly remaining: string;
405
+ /** Number of payments made */
406
+ readonly payments: number;
407
+ /** Total spent as a raw number */
408
+ readonly spentAmount: number;
409
+ /** Remaining budget as a raw number */
410
+ readonly remainingAmount: number;
411
+ /** Full payment history */
412
+ readonly ledger: readonly PaymentRecord[];
413
+ /** Spend in the last hour */
414
+ readonly hourlySpend: number;
415
+ /** Reset the budget (clears all spend history) */
416
+ reset: () => void;
417
+ }
418
+ /**
419
+ * Create a budget-controlled fetch wrapper for autonomous agents.
420
+ *
421
+ * Enforces total spend limit, per-request cap, hourly rate limit,
422
+ * and domain allowlist. Every payment is tracked in an in-memory ledger.
423
+ */
424
+ declare function createBudgetAccount(config: BudgetAccountConfig): BudgetAccount;
425
+
426
+ export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, type DiscoveredAPI, KEYPAIR_SYMBOL, type KeypairWallet, type PaymentRecord, type SearchAPIsOptions, type WrapFetchOptions, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, searchAPIs, wrapFetch };
@@ -1,32 +1,11 @@
1
- export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-H1EX6zpi.js';
2
- import { A as AccessPassClientConfig } from '../types-BQvaF8lB.js';
3
- export { b as AccessPassInfo, a as AccessPassTier, D as DEXTER_FACILITATOR_URL, U as USDC_MINT, X as X402Error } from '../types-BQvaF8lB.js';
4
- import { Transaction, VersionedTransaction, Keypair } from '@solana/web3.js';
5
- import { E as EvmWallet } from '../solana-kZcwbUK9.js';
6
- export { B as BASE_MAINNET, S as SOLANA_MAINNET, a as createEvmAdapter, c as createSolanaAdapter } from '../solana-kZcwbUK9.js';
7
- export { C as ChainAdapter, W as WalletSet } from '../types-ENcnkof8.js';
1
+ export { P as PaymentReceipt, a as X402Client, X as X402ClientConfig, c as createX402Client, f as fireImpressionBeacon, g as getPaymentReceipt, d as getSponsoredAccessInfo, b as getSponsoredRecommendations } from '../sponsored-access-DjLEKhOV.js';
2
+ import { A as AccessPassClientConfig, P as PaymentAccept } from '../types-CjLMR7qs.js';
3
+ export { b as AccessPassInfo, a as AccessPassTier, D as DEXTER_FACILITATOR_URL, U as USDC_MINT, X as X402Error } from '../types-CjLMR7qs.js';
4
+ import { Keypair } from '@solana/web3.js';
5
+ import { S as SolanaWallet, E as EvmWallet } from '../types-D1TGACsL.js';
6
+ export { B as BASE_MAINNET, C as ChainAdapter, b as SOLANA_MAINNET, W as WalletSet, a as createEvmAdapter, c as createSolanaAdapter } from '../types-D1TGACsL.js';
8
7
  export { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
9
8
 
10
- /**
11
- * Simple Fetch Wrapper for Node.js
12
- *
13
- * The easiest way to make x402 payments from Node.js scripts.
14
- * Just provide a private key and it handles everything automatically.
15
- *
16
- * @example
17
- * ```typescript
18
- * import { wrapFetch } from '@dexterai/x402/client';
19
- *
20
- * const x402Fetch = wrapFetch(fetch, {
21
- * walletPrivateKey: process.env.SOLANA_PRIVATE_KEY!,
22
- * });
23
- *
24
- * // Make a paid request - payment happens automatically
25
- * const response = await x402Fetch('https://api.example.com/protected');
26
- * const data = await response.json();
27
- * ```
28
- */
29
-
30
9
  /**
31
10
  * Options for wrapFetch
32
11
  */
@@ -81,6 +60,11 @@ interface WrapFetchOptions {
81
60
  * ```
82
61
  */
83
62
  accessPass?: AccessPassClientConfig;
63
+ /**
64
+ * Called before signing a payment. Return true to proceed, false to reject.
65
+ * Used internally by Budget Accounts — can also be set directly.
66
+ */
67
+ onPaymentRequired?: (requirements: PaymentAccept) => boolean | Promise<boolean>;
84
68
  }
85
69
  /**
86
70
  * Wrap fetch with automatic x402 payment handling
@@ -135,19 +119,27 @@ declare function wrapFetch(fetchImpl: typeof globalThis.fetch, options: WrapFetc
135
119
  * ```
136
120
  */
137
121
 
122
+ /** Symbol key for the underlying Keypair — prevents accidental exposure via console.log or JSON.stringify */
123
+ declare const KEYPAIR_SYMBOL: unique symbol;
138
124
  /**
139
- * Keypair wallet interface (compatible with SDK's SolanaWallet)
125
+ * Keypair wallet interface extends SolanaWallet with safe Keypair access.
140
126
  */
141
- interface KeypairWallet {
142
- /** Public key with toBase58() method */
143
- publicKey: {
144
- toBase58(): string;
145
- };
146
- /** Sign a transaction */
147
- signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T>;
148
- /** Get the underlying keypair (for advanced use) */
127
+ interface KeypairWallet extends SolanaWallet {
128
+ /**
129
+ * Get the underlying Keypair. Accessed via Symbol to prevent accidental
130
+ * exposure through console.log, JSON.stringify, or Object.keys.
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * import { KEYPAIR_SYMBOL } from '@dexterai/x402/client';
135
+ * const kp = wallet[KEYPAIR_SYMBOL];
136
+ * ```
137
+ */
138
+ [KEYPAIR_SYMBOL]: Keypair;
139
+ /** @deprecated Use wallet[KEYPAIR_SYMBOL] instead — this will be removed in a future major version */
149
140
  keypair: Keypair;
150
141
  }
142
+
151
143
  /**
152
144
  * Create a wallet from a Solana private key
153
145
  *
@@ -245,4 +237,190 @@ declare function createEvmKeypairWallet(privateKey: string): Promise<EvmWallet>;
245
237
  */
246
238
  declare function isEvmKeypairWallet(wallet: unknown): wallet is EvmWallet;
247
239
 
248
- export { AccessPassClientConfig, type KeypairWallet, type WrapFetchOptions, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, wrapFetch };
240
+ /**
241
+ * API Discovery — Find x402 Paid APIs
242
+ *
243
+ * Search the Dexter marketplace for x402-enabled APIs. Discover endpoints
244
+ * by category, price range, network, and quality score — then pay for them
245
+ * with the same SDK.
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * import { searchAPIs } from '@dexterai/x402/client';
250
+ *
251
+ * const results = await searchAPIs({ query: 'sentiment analysis', maxPrice: 0.10 });
252
+ * for (const api of results) {
253
+ * console.log(`${api.name}: ${api.price} — ${api.description}`);
254
+ * }
255
+ *
256
+ * // Then call one with wrapFetch:
257
+ * const response = await x402Fetch(results[0].url);
258
+ * ```
259
+ */
260
+ /**
261
+ * Search options for discovering x402 APIs
262
+ */
263
+ interface SearchAPIsOptions {
264
+ /** Search query (e.g., 'sentiment analysis', 'token price', 'image generation') */
265
+ query?: string;
266
+ /** Filter by category (e.g., 'defi', 'ai', 'data', 'social') */
267
+ category?: string;
268
+ /** Filter by payment network (e.g., 'solana', 'base', 'polygon') */
269
+ network?: string;
270
+ /** Maximum price per call in USDC */
271
+ maxPrice?: number;
272
+ /** Only return verified endpoints (quality score 75+) */
273
+ verifiedOnly?: boolean;
274
+ /** Sort order */
275
+ sort?: 'marketplace' | 'relevance' | 'quality_score' | 'settlements' | 'volume' | 'recent';
276
+ /** Maximum results to return (default 20, max 50) */
277
+ limit?: number;
278
+ /** Marketplace API URL (default: Dexter marketplace) */
279
+ marketplaceUrl?: string;
280
+ }
281
+ /**
282
+ * A discovered x402 API endpoint
283
+ */
284
+ interface DiscoveredAPI {
285
+ /** API name */
286
+ name: string;
287
+ /** Full resource URL — pass directly to wrapFetch or createX402Client.fetch */
288
+ url: string;
289
+ /** HTTP method */
290
+ method: string;
291
+ /** Price per call (formatted, e.g., '$0.05') */
292
+ price: string;
293
+ /** Price per call in USDC (raw number, null if free) */
294
+ priceUsdc: number | null;
295
+ /** Payment network */
296
+ network: string | null;
297
+ /** Human-readable description */
298
+ description: string;
299
+ /** Category (e.g., 'defi', 'ai', 'data') */
300
+ category: string;
301
+ /** Quality score (0-100, null if unscored) */
302
+ qualityScore: number | null;
303
+ /** Whether the endpoint has been verified */
304
+ verified: boolean;
305
+ /** Total number of settlements (calls) */
306
+ totalCalls: number;
307
+ /** Total volume in USDC (formatted, e.g., '$1,234.56') */
308
+ totalVolume: string | null;
309
+ /** Seller name */
310
+ seller: string | null;
311
+ /** Seller reputation score */
312
+ sellerReputation: number | null;
313
+ /** Whether authentication is required beyond payment */
314
+ authRequired: boolean;
315
+ /** Last time someone called this API */
316
+ lastActive: string | null;
317
+ }
318
+ /**
319
+ * Search the Dexter marketplace for x402 paid APIs.
320
+ *
321
+ * Returns a list of discovered endpoints that can be called directly
322
+ * with `wrapFetch` or `createX402Client.fetch`.
323
+ *
324
+ * @example Find AI APIs under $0.10
325
+ * ```typescript
326
+ * const apis = await searchAPIs({ query: 'ai', maxPrice: 0.10 });
327
+ * ```
328
+ *
329
+ * @example Browse all verified DeFi tools
330
+ * ```typescript
331
+ * const apis = await searchAPIs({ category: 'defi', verifiedOnly: true });
332
+ * ```
333
+ *
334
+ * @example Find cheapest APIs on Solana
335
+ * ```typescript
336
+ * const apis = await searchAPIs({ network: 'solana', sort: 'quality_score' });
337
+ * ```
338
+ */
339
+ declare function searchAPIs(options?: SearchAPIsOptions): Promise<DiscoveredAPI[]>;
340
+
341
+ /**
342
+ * Budget Account — Autonomous Agent Spending Controls
343
+ *
344
+ * Wraps the x402 client with a spending limit, per-request cap,
345
+ * per-hour rate limit, and optional domain allowlist. Tracks cumulative
346
+ * spend and exposes remaining budget. When the budget is exhausted,
347
+ * requests throw instead of paying.
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * import { createBudgetAccount } from '@dexterai/x402/client';
352
+ *
353
+ * const agent = createBudgetAccount({
354
+ * walletPrivateKey: process.env.SOLANA_PRIVATE_KEY,
355
+ * budget: {
356
+ * total: '50.00', // $50 total budget
357
+ * perRequest: '1.00', // max $1 per request
358
+ * perHour: '10.00', // max $10/hour
359
+ * },
360
+ * allowedDomains: ['api.example.com', 'data.example.com'],
361
+ * });
362
+ *
363
+ * const response = await agent.fetch('https://api.example.com/data');
364
+ * console.log(agent.spent); // '$0.05'
365
+ * console.log(agent.remaining); // '$49.95'
366
+ * console.log(agent.payments); // 1
367
+ * ```
368
+ */
369
+
370
+ /** Budget configuration */
371
+ interface BudgetConfig {
372
+ /** Total spending limit in USD (e.g., '50.00') */
373
+ total: string;
374
+ /** Maximum amount per single request in USD (e.g., '1.00'). Optional. */
375
+ perRequest?: string;
376
+ /** Maximum spend per hour in USD (e.g., '10.00'). Optional. */
377
+ perHour?: string;
378
+ }
379
+ /** Budget Account configuration — extends WrapFetchOptions with spending controls */
380
+ interface BudgetAccountConfig extends WrapFetchOptions {
381
+ /** Spending limits */
382
+ budget: BudgetConfig;
383
+ /** Restrict payments to these domains only. If omitted, all domains allowed. */
384
+ allowedDomains?: string[];
385
+ }
386
+ /** A payment record in the spend ledger */
387
+ interface PaymentRecord {
388
+ /** Amount paid in USD */
389
+ amount: number;
390
+ /** Domain that was paid */
391
+ domain: string;
392
+ /** CAIP-2 network used */
393
+ network: string;
394
+ /** Timestamp (ms) */
395
+ timestamp: number;
396
+ }
397
+ /** Budget Account — fetch with spending controls */
398
+ interface BudgetAccount {
399
+ /** Payment-aware fetch with budget enforcement */
400
+ fetch: typeof globalThis.fetch;
401
+ /** Total amount spent (formatted, e.g., '$12.34') */
402
+ readonly spent: string;
403
+ /** Remaining budget (formatted, e.g., '$37.66') */
404
+ readonly remaining: string;
405
+ /** Number of payments made */
406
+ readonly payments: number;
407
+ /** Total spent as a raw number */
408
+ readonly spentAmount: number;
409
+ /** Remaining budget as a raw number */
410
+ readonly remainingAmount: number;
411
+ /** Full payment history */
412
+ readonly ledger: readonly PaymentRecord[];
413
+ /** Spend in the last hour */
414
+ readonly hourlySpend: number;
415
+ /** Reset the budget (clears all spend history) */
416
+ reset: () => void;
417
+ }
418
+ /**
419
+ * Create a budget-controlled fetch wrapper for autonomous agents.
420
+ *
421
+ * Enforces total spend limit, per-request cap, hourly rate limit,
422
+ * and domain allowlist. Every payment is tracked in an in-memory ledger.
423
+ */
424
+ declare function createBudgetAccount(config: BudgetAccountConfig): BudgetAccount;
425
+
426
+ export { AccessPassClientConfig, type BudgetAccount, type BudgetAccountConfig, type BudgetConfig, type DiscoveredAPI, KEYPAIR_SYMBOL, type KeypairWallet, type PaymentRecord, type SearchAPIsOptions, type WrapFetchOptions, createBudgetAccount, createEvmKeypairWallet, createKeypairWallet, isEvmKeypairWallet, isKeypairWallet, searchAPIs, wrapFetch };