uvd-x402-sdk 2.0.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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +782 -0
  3. package/dist/index-BrBqP1I8.d.ts +199 -0
  4. package/dist/index-D6Sr4ARD.d.mts +429 -0
  5. package/dist/index-D6Sr4ARD.d.ts +429 -0
  6. package/dist/index-DJ4Cvrev.d.mts +199 -0
  7. package/dist/index.d.mts +3 -0
  8. package/dist/index.d.ts +3 -0
  9. package/dist/index.js +1178 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/index.mjs +1146 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/dist/providers/evm/index.d.mts +84 -0
  14. package/dist/providers/evm/index.d.ts +84 -0
  15. package/dist/providers/evm/index.js +740 -0
  16. package/dist/providers/evm/index.js.map +1 -0
  17. package/dist/providers/evm/index.mjs +735 -0
  18. package/dist/providers/evm/index.mjs.map +1 -0
  19. package/dist/providers/near/index.d.mts +99 -0
  20. package/dist/providers/near/index.d.ts +99 -0
  21. package/dist/providers/near/index.js +483 -0
  22. package/dist/providers/near/index.js.map +1 -0
  23. package/dist/providers/near/index.mjs +478 -0
  24. package/dist/providers/near/index.mjs.map +1 -0
  25. package/dist/providers/solana/index.d.mts +115 -0
  26. package/dist/providers/solana/index.d.ts +115 -0
  27. package/dist/providers/solana/index.js +771 -0
  28. package/dist/providers/solana/index.js.map +1 -0
  29. package/dist/providers/solana/index.mjs +765 -0
  30. package/dist/providers/solana/index.mjs.map +1 -0
  31. package/dist/providers/stellar/index.d.mts +67 -0
  32. package/dist/providers/stellar/index.d.ts +67 -0
  33. package/dist/providers/stellar/index.js +306 -0
  34. package/dist/providers/stellar/index.js.map +1 -0
  35. package/dist/providers/stellar/index.mjs +301 -0
  36. package/dist/providers/stellar/index.mjs.map +1 -0
  37. package/dist/react/index.d.mts +73 -0
  38. package/dist/react/index.d.ts +73 -0
  39. package/dist/react/index.js +1218 -0
  40. package/dist/react/index.js.map +1 -0
  41. package/dist/react/index.mjs +1211 -0
  42. package/dist/react/index.mjs.map +1 -0
  43. package/dist/utils/index.d.mts +103 -0
  44. package/dist/utils/index.d.ts +103 -0
  45. package/dist/utils/index.js +575 -0
  46. package/dist/utils/index.js.map +1 -0
  47. package/dist/utils/index.mjs +562 -0
  48. package/dist/utils/index.mjs.map +1 -0
  49. package/package.json +149 -0
  50. package/src/chains/index.ts +539 -0
  51. package/src/client/X402Client.ts +663 -0
  52. package/src/client/index.ts +1 -0
  53. package/src/index.ts +166 -0
  54. package/src/providers/evm/index.ts +394 -0
  55. package/src/providers/near/index.ts +664 -0
  56. package/src/providers/solana/index.ts +489 -0
  57. package/src/providers/stellar/index.ts +376 -0
  58. package/src/react/index.tsx +417 -0
  59. package/src/types/index.ts +561 -0
  60. package/src/utils/index.ts +20 -0
  61. package/src/utils/x402.ts +295 -0
@@ -0,0 +1,429 @@
1
+ /**
2
+ * uvd-x402-sdk - Type Definitions
3
+ *
4
+ * Core TypeScript interfaces for the x402 payment SDK.
5
+ * These types define the contract between the SDK and consuming applications.
6
+ */
7
+ /**
8
+ * Network type categorization
9
+ * - 'evm': Ethereum Virtual Machine compatible chains (use EIP-712)
10
+ * - 'svm': Solana Virtual Machine chains (Solana, Fogo) (use SPL tokens)
11
+ * - 'stellar': Stellar network (use Soroban)
12
+ * - 'near': NEAR Protocol (use NEP-366)
13
+ *
14
+ * @deprecated 'solana' type is deprecated, use 'svm' instead
15
+ */
16
+ type NetworkType = 'evm' | 'svm' | 'solana' | 'stellar' | 'near';
17
+ /**
18
+ * USDC token configuration for a specific chain
19
+ */
20
+ interface USDCConfig {
21
+ /** Contract/mint address */
22
+ address: string;
23
+ /** Token decimals (6 for most chains, 7 for Stellar, 18 for BSC) */
24
+ decimals: number;
25
+ /** Token name for EIP-712 domain (e.g., "USD Coin" or "USDC") */
26
+ name: string;
27
+ /** Token version for EIP-712 domain */
28
+ version: string;
29
+ }
30
+ /**
31
+ * Native currency configuration
32
+ */
33
+ interface NativeCurrency {
34
+ name: string;
35
+ symbol: string;
36
+ decimals: number;
37
+ }
38
+ /**
39
+ * Complete chain configuration
40
+ */
41
+ interface ChainConfig {
42
+ /** Numeric chain ID (0 for non-EVM chains) */
43
+ chainId: number;
44
+ /** Hex-encoded chain ID for wallet_switchEthereumChain */
45
+ chainIdHex: string;
46
+ /** Internal chain identifier (e.g., 'base', 'solana') */
47
+ name: string;
48
+ /** Human-readable display name */
49
+ displayName: string;
50
+ /** Network type for routing */
51
+ networkType: NetworkType;
52
+ /** Primary RPC endpoint URL */
53
+ rpcUrl: string;
54
+ /** Block explorer base URL */
55
+ explorerUrl: string;
56
+ /** Native currency info */
57
+ nativeCurrency: NativeCurrency;
58
+ /** USDC token configuration */
59
+ usdc: USDCConfig;
60
+ /** x402 facilitator configuration */
61
+ x402: {
62
+ facilitatorUrl: string;
63
+ enabled: boolean;
64
+ };
65
+ }
66
+ /**
67
+ * Current wallet connection state
68
+ */
69
+ interface WalletState {
70
+ /** Whether a wallet is currently connected */
71
+ connected: boolean;
72
+ /** Connected wallet address (null if not connected) */
73
+ address: string | null;
74
+ /** Current chain ID (null for non-EVM or disconnected) */
75
+ chainId: number | null;
76
+ /** Current network name */
77
+ network: string | null;
78
+ /** Network type of connected wallet */
79
+ networkType: NetworkType | null;
80
+ /** USDC balance on current chain (null if unknown) */
81
+ balance: string | null;
82
+ }
83
+ /**
84
+ * Wallet adapter interface for different wallet types
85
+ */
86
+ interface WalletAdapter {
87
+ /** Unique identifier for this wallet type */
88
+ readonly id: string;
89
+ /** Display name */
90
+ readonly name: string;
91
+ /** Network type this adapter supports */
92
+ readonly networkType: NetworkType;
93
+ /** Check if this wallet is available/installed */
94
+ isAvailable(): boolean;
95
+ /** Connect to the wallet */
96
+ connect(chainName?: string): Promise<string>;
97
+ /** Disconnect from the wallet */
98
+ disconnect(): Promise<void>;
99
+ /** Switch to a different chain (EVM only) */
100
+ switchChain?(chainName: string): Promise<void>;
101
+ /** Sign a payment payload */
102
+ signPayment(paymentInfo: PaymentInfo, chainConfig: ChainConfig): Promise<string>;
103
+ /** Check USDC balance */
104
+ getBalance(chainConfig: ChainConfig): Promise<string>;
105
+ /** Get current address */
106
+ getAddress(): string | null;
107
+ /** Get current chain ID (EVM only) */
108
+ getChainId?(): number | null;
109
+ }
110
+ /**
111
+ * EIP-712 domain for typed data signing
112
+ */
113
+ interface EIP712Domain {
114
+ name: string;
115
+ version: string;
116
+ chainId: number;
117
+ verifyingContract: string;
118
+ }
119
+ /**
120
+ * EIP-712 type definitions
121
+ */
122
+ interface EIP712Types {
123
+ [typeName: string]: Array<{
124
+ name: string;
125
+ type: string;
126
+ }>;
127
+ }
128
+ /**
129
+ * Payment information returned by backend on 402 response
130
+ */
131
+ interface PaymentInfo {
132
+ /** Default recipient address */
133
+ recipient: string;
134
+ /** Network-specific recipient addresses */
135
+ recipients?: {
136
+ evm?: string;
137
+ solana?: string;
138
+ near?: string;
139
+ stellar?: string;
140
+ };
141
+ /** Facilitator address (for Solana fee payer) */
142
+ facilitator?: string;
143
+ /** Amount in USD (e.g., "10.00") */
144
+ amount: string;
145
+ /** Token symbol (usually "USDC") */
146
+ token?: string;
147
+ /** Network hint from backend */
148
+ network?: string;
149
+ /** Supported chain IDs */
150
+ supportedChains?: number[];
151
+ }
152
+ /**
153
+ * Simple payment request from application
154
+ */
155
+ interface PaymentRequest {
156
+ /** Amount in USDC (e.g., "10.00") */
157
+ amount: string;
158
+ /** Override recipient address (optional) */
159
+ recipient?: string;
160
+ /** Application-specific metadata */
161
+ metadata?: Record<string, unknown>;
162
+ }
163
+ /**
164
+ * Result of a payment operation
165
+ */
166
+ interface PaymentResult {
167
+ /** Whether payment was successful */
168
+ success: boolean;
169
+ /** Base64-encoded X-PAYMENT header value */
170
+ paymentHeader: string;
171
+ /** Transaction hash (if available) */
172
+ transactionHash?: string;
173
+ /** Network where payment was made */
174
+ network: string;
175
+ /** Payer address */
176
+ payer?: string;
177
+ /** Error message (if success is false) */
178
+ error?: string;
179
+ }
180
+ /**
181
+ * EVM payment payload (ERC-3009 TransferWithAuthorization)
182
+ */
183
+ interface EVMPaymentPayload {
184
+ from: string;
185
+ to: string;
186
+ value: string;
187
+ validAfter: number;
188
+ validBefore: number;
189
+ nonce: string;
190
+ v: number;
191
+ r: string;
192
+ s: string;
193
+ chainId: number;
194
+ token: string;
195
+ }
196
+ /**
197
+ * Solana payment payload (partially-signed transaction)
198
+ */
199
+ interface SolanaPaymentPayload {
200
+ /** Base64-encoded serialized transaction */
201
+ transaction: string;
202
+ }
203
+ /**
204
+ * Stellar payment payload (Soroban authorization)
205
+ */
206
+ interface StellarPaymentPayload {
207
+ /** Sender G... public key */
208
+ from: string;
209
+ /** Recipient G... public key */
210
+ to: string;
211
+ /** Amount in stroops (7 decimals) */
212
+ amount: string;
213
+ /** USDC SAC contract address */
214
+ tokenContract: string;
215
+ /** Base64 XDR-encoded SorobanAuthorizationEntry */
216
+ authorizationEntryXdr: string;
217
+ /** Random 64-bit nonce */
218
+ nonce: number;
219
+ /** Ledger when authorization expires */
220
+ signatureExpirationLedger: number;
221
+ }
222
+ /**
223
+ * NEAR payment payload (NEP-366 meta-transaction)
224
+ */
225
+ interface NEARPaymentPayload {
226
+ /** Base64 Borsh-encoded SignedDelegateAction */
227
+ signedDelegateAction: string;
228
+ network: 'near';
229
+ }
230
+ /**
231
+ * Union type for all payment payloads
232
+ */
233
+ type PaymentPayload = EVMPaymentPayload | SolanaPaymentPayload | StellarPaymentPayload | NEARPaymentPayload;
234
+ /**
235
+ * x402 protocol version
236
+ */
237
+ type X402Version = 1 | 2;
238
+ /**
239
+ * CAIP-2 chain identifiers for x402 v2
240
+ * @see https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
241
+ */
242
+ declare const CAIP2_IDENTIFIERS: Record<string, string>;
243
+ /**
244
+ * Reverse mapping from CAIP-2 to chain name
245
+ */
246
+ declare const CAIP2_TO_CHAIN: Record<string, string>;
247
+ /**
248
+ * x402 v1 header structure (network as string)
249
+ */
250
+ interface X402HeaderV1 {
251
+ x402Version: 1;
252
+ scheme: 'exact';
253
+ network: string;
254
+ payload: X402PayloadData;
255
+ }
256
+ /**
257
+ * x402 v2 payment option
258
+ */
259
+ interface X402PaymentOption {
260
+ network: string;
261
+ asset: string;
262
+ amount: string;
263
+ facilitator?: string;
264
+ }
265
+ /**
266
+ * x402 v2 header structure (CAIP-2 network, accepts array)
267
+ */
268
+ interface X402HeaderV2 {
269
+ x402Version: 2;
270
+ scheme: 'exact';
271
+ network: string;
272
+ payload: X402PayloadData;
273
+ accepts?: X402PaymentOption[];
274
+ }
275
+ /**
276
+ * Union type for both v1 and v2 headers
277
+ */
278
+ type X402Header = X402HeaderV1 | X402HeaderV2;
279
+ /**
280
+ * EVM-specific payload in x402 header
281
+ */
282
+ interface X402EVMPayload {
283
+ signature: string;
284
+ authorization: {
285
+ from: string;
286
+ to: string;
287
+ value: string;
288
+ validAfter: string;
289
+ validBefore: string;
290
+ nonce: string;
291
+ };
292
+ }
293
+ /**
294
+ * Solana-specific payload in x402 header
295
+ */
296
+ interface X402SolanaPayload {
297
+ transaction: string;
298
+ }
299
+ /**
300
+ * Stellar-specific payload in x402 header
301
+ */
302
+ interface X402StellarPayload {
303
+ from: string;
304
+ to: string;
305
+ amount: string;
306
+ tokenContract: string;
307
+ authorizationEntryXdr: string;
308
+ nonce: number;
309
+ signatureExpirationLedger: number;
310
+ }
311
+ /**
312
+ * NEAR-specific payload in x402 header
313
+ */
314
+ interface X402NEARPayload {
315
+ signedDelegateAction: string;
316
+ }
317
+ /**
318
+ * Union of all x402 payload types
319
+ */
320
+ type X402PayloadData = X402EVMPayload | X402SolanaPayload | X402StellarPayload | X402NEARPayload;
321
+ /**
322
+ * Multi-payment configuration for supporting multiple networks
323
+ */
324
+ interface MultiPaymentConfig {
325
+ /** Networks to support (e.g., ['base', 'solana', 'stellar', 'near']) */
326
+ networks: string[];
327
+ /** Default network if user hasn't selected one */
328
+ defaultNetwork?: string;
329
+ /** Whether to auto-detect user's preferred network based on wallet */
330
+ autoDetect?: boolean;
331
+ }
332
+ /**
333
+ * SDK client configuration options
334
+ */
335
+ interface X402ClientConfig {
336
+ /** Facilitator URL (default: https://facilitator.ultravioletadao.xyz) */
337
+ facilitatorUrl?: string;
338
+ /** Default chain to connect to */
339
+ defaultChain?: string;
340
+ /** Auto-connect on initialization */
341
+ autoConnect?: boolean;
342
+ /** Enable debug logging */
343
+ debug?: boolean;
344
+ /** Custom chain configurations (override defaults) */
345
+ customChains?: Record<string, Partial<ChainConfig>>;
346
+ /** Wallet preference order */
347
+ walletPreference?: string[];
348
+ /** Custom RPC URLs (override defaults) */
349
+ rpcOverrides?: Record<string, string>;
350
+ /**
351
+ * x402 protocol version to use
352
+ * - 1: Classic format with network as string (e.g., "base")
353
+ * - 2: CAIP-2 format with accepts array (e.g., "eip155:8453")
354
+ * - 'auto': Auto-detect from 402 response (default)
355
+ */
356
+ x402Version?: X402Version | 'auto';
357
+ /** Multi-payment configuration for supporting multiple networks */
358
+ multiPayment?: MultiPaymentConfig;
359
+ }
360
+ /**
361
+ * Default configuration values
362
+ */
363
+ declare const DEFAULT_CONFIG: Required<Pick<X402ClientConfig, 'facilitatorUrl' | 'defaultChain' | 'autoConnect' | 'debug' | 'x402Version'>>;
364
+ /**
365
+ * Balance information for a single network
366
+ */
367
+ interface NetworkBalance {
368
+ /** Chain name */
369
+ chainName: string;
370
+ /** Human-readable display name */
371
+ displayName: string;
372
+ /** Formatted balance (e.g., "15.50") or null if loading/error */
373
+ balance: string | null;
374
+ /** Whether balance is currently being fetched */
375
+ isLoading: boolean;
376
+ /** Error message if fetch failed */
377
+ error: string | null;
378
+ }
379
+ /**
380
+ * Events emitted by the SDK client
381
+ */
382
+ type X402Event = 'connect' | 'disconnect' | 'chainChanged' | 'accountChanged' | 'balanceChanged' | 'paymentStarted' | 'paymentSigned' | 'paymentCompleted' | 'paymentFailed';
383
+ /**
384
+ * Event data types
385
+ */
386
+ interface X402EventData {
387
+ connect: WalletState;
388
+ disconnect: void;
389
+ chainChanged: {
390
+ chainId: number;
391
+ chainName: string;
392
+ };
393
+ accountChanged: {
394
+ address: string;
395
+ };
396
+ balanceChanged: {
397
+ balance: string;
398
+ };
399
+ paymentStarted: {
400
+ amount: string;
401
+ network: string;
402
+ };
403
+ paymentSigned: {
404
+ paymentHeader: string;
405
+ };
406
+ paymentCompleted: PaymentResult;
407
+ paymentFailed: {
408
+ error: string;
409
+ code: X402ErrorCode;
410
+ };
411
+ }
412
+ /**
413
+ * Event handler type
414
+ */
415
+ type X402EventHandler<E extends X402Event> = (data: X402EventData[E]) => void;
416
+ /**
417
+ * Error codes for categorizing errors
418
+ */
419
+ type X402ErrorCode = 'WALLET_NOT_FOUND' | 'WALLET_NOT_CONNECTED' | 'WALLET_CONNECTION_REJECTED' | 'WALLET_CONNECTION_TIMEOUT' | 'CHAIN_NOT_SUPPORTED' | 'CHAIN_SWITCH_REJECTED' | 'INSUFFICIENT_BALANCE' | 'SIGNATURE_REJECTED' | 'PAYMENT_FAILED' | 'PAYMENT_TIMEOUT' | 'NETWORK_ERROR' | 'INVALID_CONFIG' | 'INVALID_AMOUNT' | 'INVALID_RECIPIENT' | 'UNKNOWN_ERROR';
420
+ /**
421
+ * SDK-specific error class
422
+ */
423
+ declare class X402Error extends Error {
424
+ readonly code: X402ErrorCode;
425
+ readonly details?: unknown;
426
+ constructor(message: string, code: X402ErrorCode, details?: unknown);
427
+ }
428
+
429
+ export { CAIP2_TO_CHAIN as A, type ChainConfig as C, DEFAULT_CONFIG as D, type EIP712Domain as E, type MultiPaymentConfig as M, type NativeCurrency as N, type PaymentInfo as P, type SolanaPaymentPayload as S, type USDCConfig as U, type WalletState as W, type X402Version as X, type NetworkType as a, type WalletAdapter as b, type EIP712Types as c, type PaymentRequest as d, type PaymentResult as e, type PaymentPayload as f, type EVMPaymentPayload as g, type StellarPaymentPayload as h, type NEARPaymentPayload as i, type X402Header as j, type X402HeaderV1 as k, type X402HeaderV2 as l, type X402PaymentOption as m, type X402PayloadData as n, type X402EVMPayload as o, type X402SolanaPayload as p, type X402StellarPayload as q, type X402NEARPayload as r, type X402ClientConfig as s, type NetworkBalance as t, type X402Event as u, type X402EventData as v, type X402EventHandler as w, type X402ErrorCode as x, X402Error as y, CAIP2_IDENTIFIERS as z };
@@ -0,0 +1,199 @@
1
+ import { s as X402ClientConfig, P as PaymentInfo, e as PaymentResult, W as WalletState, C as ChainConfig, u as X402Event, w as X402EventHandler, a as NetworkType } from './index-D6Sr4ARD.mjs';
2
+
3
+ /**
4
+ * uvd-x402-sdk - Main Client
5
+ *
6
+ * The X402Client is the primary entry point for the SDK.
7
+ * It manages wallet connections, chain switching, and payment creation.
8
+ */
9
+
10
+ /**
11
+ * X402Client - Main SDK client for x402 payments
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { X402Client } from 'uvd-x402-sdk';
16
+ *
17
+ * const client = new X402Client({ defaultChain: 'base' });
18
+ *
19
+ * // Connect wallet
20
+ * await client.connect('base');
21
+ *
22
+ * // Create payment
23
+ * const result = await client.createPayment({
24
+ * recipient: '0x...',
25
+ * amount: '10.00',
26
+ * });
27
+ *
28
+ * // Use result.paymentHeader in your API request
29
+ * ```
30
+ */
31
+ declare class X402Client {
32
+ private readonly config;
33
+ private provider;
34
+ private signer;
35
+ private connectedAddress;
36
+ private currentChainId;
37
+ private currentNetwork;
38
+ private currentChainName;
39
+ private eventHandlers;
40
+ constructor(config?: X402ClientConfig);
41
+ /**
42
+ * Connect to a wallet on the specified chain
43
+ */
44
+ connect(chainName?: string): Promise<string>;
45
+ /**
46
+ * Disconnect the current wallet
47
+ */
48
+ disconnect(): Promise<void>;
49
+ /**
50
+ * Switch to a different chain (EVM only)
51
+ */
52
+ switchChain(chainName: string): Promise<void>;
53
+ /**
54
+ * Create a payment authorization
55
+ *
56
+ * @param paymentInfo - Payment information from 402 response
57
+ * @returns Payment result with encoded X-PAYMENT header
58
+ */
59
+ createPayment(paymentInfo: PaymentInfo): Promise<PaymentResult>;
60
+ /**
61
+ * Check USDC balance on current chain
62
+ */
63
+ getBalance(): Promise<string>;
64
+ /**
65
+ * Get current wallet state
66
+ */
67
+ getState(): WalletState;
68
+ /**
69
+ * Get connected wallet address
70
+ */
71
+ getAddress(): string | null;
72
+ /**
73
+ * Get current chain ID
74
+ */
75
+ getChainId(): number | null;
76
+ /**
77
+ * Get current chain name
78
+ */
79
+ getChainName(): string | null;
80
+ /**
81
+ * Get current chain display name
82
+ */
83
+ getChainDisplayName(): string | null;
84
+ /**
85
+ * Check if wallet is connected
86
+ */
87
+ isConnected(): boolean;
88
+ /**
89
+ * Get list of enabled chains
90
+ */
91
+ getEnabledChains(): ChainConfig[];
92
+ /**
93
+ * Get chain config by name
94
+ */
95
+ getChain(name: string): ChainConfig | undefined;
96
+ /**
97
+ * Subscribe to an event
98
+ */
99
+ on<E extends X402Event>(event: E, handler: X402EventHandler<E>): () => void;
100
+ /**
101
+ * Unsubscribe from an event
102
+ */
103
+ off<E extends X402Event>(event: E, handler: X402EventHandler<E>): void;
104
+ private connectEVMWallet;
105
+ private switchEVMChain;
106
+ private setupEVMEventListeners;
107
+ private createEVMPayment;
108
+ private encodeEVMPaymentHeader;
109
+ private getEVMBalance;
110
+ private getRecipientForNetwork;
111
+ private emit;
112
+ private log;
113
+ }
114
+ declare global {
115
+ interface Window {
116
+ ethereum?: {
117
+ request: (args: {
118
+ method: string;
119
+ params?: unknown[];
120
+ }) => Promise<unknown>;
121
+ on?: (event: string, handler: (...args: unknown[]) => void) => void;
122
+ removeListener?: (event: string, handler: (...args: unknown[]) => void) => void;
123
+ };
124
+ }
125
+ }
126
+
127
+ /**
128
+ * uvd-x402-sdk - Chain Registry
129
+ *
130
+ * Complete configuration for all 15 supported blockchain networks.
131
+ * EVM chains (11): Use ERC-3009 TransferWithAuthorization
132
+ * SVM chains (2): Solana and Fogo - Use SPL tokens with partially-signed transactions
133
+ * Stellar (1): Uses Soroban authorization entries
134
+ * NEAR (1): Uses NEP-366 meta-transactions
135
+ */
136
+
137
+ /**
138
+ * Default facilitator URL for x402 payments
139
+ */
140
+ declare const DEFAULT_FACILITATOR_URL = "https://facilitator.ultravioletadao.xyz";
141
+ /**
142
+ * All supported chains configuration
143
+ *
144
+ * To add a new chain:
145
+ * 1. Add chain config below with all required fields
146
+ * 2. Verify USDC contract supports ERC-3009 (transferWithAuthorization) for EVM chains
147
+ * 3. Test on testnet first before enabling
148
+ */
149
+ declare const SUPPORTED_CHAINS: Record<string, ChainConfig>;
150
+ /**
151
+ * Default chain for new users
152
+ */
153
+ declare const DEFAULT_CHAIN = "base";
154
+ /**
155
+ * Get chain config by chain ID
156
+ */
157
+ declare function getChainById(chainId: number): ChainConfig | undefined;
158
+ /**
159
+ * Get chain config by name (case-insensitive)
160
+ */
161
+ declare function getChainByName(name: string): ChainConfig | undefined;
162
+ /**
163
+ * Check if a chain is supported
164
+ */
165
+ declare function isChainSupported(chainIdOrName: number | string): boolean;
166
+ /**
167
+ * Get list of enabled chains
168
+ */
169
+ declare function getEnabledChains(): ChainConfig[];
170
+ /**
171
+ * Get list of chains by network type
172
+ */
173
+ declare function getChainsByNetworkType(networkType: NetworkType): ChainConfig[];
174
+ /**
175
+ * Get all EVM chain IDs (for wallet_switchEthereumChain)
176
+ */
177
+ declare function getEVMChainIds(): number[];
178
+ /**
179
+ * Get list of SVM chains (Solana, Fogo)
180
+ */
181
+ declare function getSVMChains(): ChainConfig[];
182
+ /**
183
+ * Check if a chain is SVM-based (Solana Virtual Machine)
184
+ */
185
+ declare function isSVMChain(chainName: string): boolean;
186
+ /**
187
+ * Get network type from chain name
188
+ */
189
+ declare function getNetworkType(chainName: string): NetworkType | undefined;
190
+ /**
191
+ * Format transaction URL for block explorer
192
+ */
193
+ declare function getExplorerTxUrl(chainName: string, txHash: string): string | null;
194
+ /**
195
+ * Format address URL for block explorer
196
+ */
197
+ declare function getExplorerAddressUrl(chainName: string, address: string): string | null;
198
+
199
+ export { DEFAULT_CHAIN as D, SUPPORTED_CHAINS as S, X402Client as X, DEFAULT_FACILITATOR_URL as a, getChainByName as b, getEnabledChains as c, getChainsByNetworkType as d, getEVMChainIds as e, getSVMChains as f, getChainById as g, isSVMChain as h, isChainSupported as i, getNetworkType as j, getExplorerTxUrl as k, getExplorerAddressUrl as l };
@@ -0,0 +1,3 @@
1
+ export { D as DEFAULT_CHAIN, a as DEFAULT_FACILITATOR_URL, S as SUPPORTED_CHAINS, X as X402Client, g as getChainById, b as getChainByName, d as getChainsByNetworkType, e as getEVMChainIds, c as getEnabledChains, l as getExplorerAddressUrl, k as getExplorerTxUrl, j as getNetworkType, f as getSVMChains, i as isChainSupported, h as isSVMChain } from './index-DJ4Cvrev.mjs';
2
+ export { caip2ToChain, chainToCAIP2, convertX402Header, createX402Header, createX402V1Header, createX402V2Header, decodeX402Header, detectX402Version, encodeX402Header, generatePaymentOptions, isCAIP2Format, parseNetworkIdentifier } from './utils/index.mjs';
3
+ export { z as CAIP2_IDENTIFIERS, A as CAIP2_TO_CHAIN, C as ChainConfig, D as DEFAULT_CONFIG, E as EIP712Domain, c as EIP712Types, g as EVMPaymentPayload, M as MultiPaymentConfig, i as NEARPaymentPayload, N as NativeCurrency, t as NetworkBalance, a as NetworkType, P as PaymentInfo, f as PaymentPayload, d as PaymentRequest, e as PaymentResult, S as SolanaPaymentPayload, h as StellarPaymentPayload, U as USDCConfig, b as WalletAdapter, W as WalletState, s as X402ClientConfig, o as X402EVMPayload, y as X402Error, x as X402ErrorCode, u as X402Event, v as X402EventData, w as X402EventHandler, j as X402Header, k as X402HeaderV1, l as X402HeaderV2, r as X402NEARPayload, n as X402PayloadData, m as X402PaymentOption, p as X402SolanaPayload, q as X402StellarPayload, X as X402Version } from './index-D6Sr4ARD.mjs';
@@ -0,0 +1,3 @@
1
+ export { D as DEFAULT_CHAIN, a as DEFAULT_FACILITATOR_URL, S as SUPPORTED_CHAINS, X as X402Client, g as getChainById, b as getChainByName, d as getChainsByNetworkType, e as getEVMChainIds, c as getEnabledChains, l as getExplorerAddressUrl, k as getExplorerTxUrl, j as getNetworkType, f as getSVMChains, i as isChainSupported, h as isSVMChain } from './index-BrBqP1I8.js';
2
+ export { caip2ToChain, chainToCAIP2, convertX402Header, createX402Header, createX402V1Header, createX402V2Header, decodeX402Header, detectX402Version, encodeX402Header, generatePaymentOptions, isCAIP2Format, parseNetworkIdentifier } from './utils/index.js';
3
+ export { z as CAIP2_IDENTIFIERS, A as CAIP2_TO_CHAIN, C as ChainConfig, D as DEFAULT_CONFIG, E as EIP712Domain, c as EIP712Types, g as EVMPaymentPayload, M as MultiPaymentConfig, i as NEARPaymentPayload, N as NativeCurrency, t as NetworkBalance, a as NetworkType, P as PaymentInfo, f as PaymentPayload, d as PaymentRequest, e as PaymentResult, S as SolanaPaymentPayload, h as StellarPaymentPayload, U as USDCConfig, b as WalletAdapter, W as WalletState, s as X402ClientConfig, o as X402EVMPayload, y as X402Error, x as X402ErrorCode, u as X402Event, v as X402EventData, w as X402EventHandler, j as X402Header, k as X402HeaderV1, l as X402HeaderV2, r as X402NEARPayload, n as X402PayloadData, m as X402PaymentOption, p as X402SolanaPayload, q as X402StellarPayload, X as X402Version } from './index-D6Sr4ARD.js';