@smoothsend/sdk 1.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.
@@ -0,0 +1,2072 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+
3
+ /**
4
+ * Error handling system for SmoothSend SDK v2
5
+ * Provides typed error classes for different failure scenarios
6
+ *
7
+ * @remarks
8
+ * All SDK errors extend SmoothSendError for consistent error handling
9
+ * Use instanceof checks to handle specific error types
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * try {
14
+ * await sdk.transfer(request, wallet);
15
+ * } catch (error) {
16
+ * if (error instanceof AuthenticationError) {
17
+ * console.error('Invalid API key');
18
+ * } else if (error instanceof RateLimitError) {
19
+ * console.error('Rate limit exceeded');
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ /**
25
+ * Base error class for all SmoothSend SDK errors
26
+ *
27
+ * @remarks
28
+ * All SDK-specific errors extend this class
29
+ * Contains error code, HTTP status code, and additional details
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * throw new SmoothSendError(
34
+ * 'Something went wrong',
35
+ * 'CUSTOM_ERROR',
36
+ * 500,
37
+ * { additionalInfo: 'details' }
38
+ * );
39
+ * ```
40
+ */
41
+ declare class SmoothSendError extends Error {
42
+ code: string;
43
+ statusCode?: number | undefined;
44
+ details?: any | undefined;
45
+ /**
46
+ * Creates a new SmoothSendError
47
+ *
48
+ * @param message - Human-readable error message
49
+ * @param code - Error code for programmatic handling
50
+ * @param statusCode - HTTP status code (if applicable)
51
+ * @param details - Additional error details
52
+ */
53
+ constructor(message: string, code: string, statusCode?: number | undefined, details?: any | undefined);
54
+ }
55
+ /**
56
+ * Authentication error - thrown when API key is invalid, missing, or expired
57
+ *
58
+ * @remarks
59
+ * HTTP Status Code: 401
60
+ * Indicates authentication failure with the proxy worker
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * try {
65
+ * await sdk.transfer(request, wallet);
66
+ * } catch (error) {
67
+ * if (error instanceof AuthenticationError) {
68
+ * console.error('Invalid API key:', error.message);
69
+ * console.log('Get a new key at:', error.details.suggestion);
70
+ * }
71
+ * }
72
+ * ```
73
+ */
74
+ declare class AuthenticationError extends SmoothSendError {
75
+ /**
76
+ * Creates a new AuthenticationError
77
+ *
78
+ * @param message - Human-readable error message
79
+ * @param details - Additional error details
80
+ */
81
+ constructor(message: string, details?: any);
82
+ }
83
+ /**
84
+ * Rate limit error - thrown when request rate limit is exceeded
85
+ *
86
+ * @remarks
87
+ * HTTP Status Code: 429
88
+ * Contains rate limit details including reset time
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * try {
93
+ * await sdk.transfer(request, wallet);
94
+ * } catch (error) {
95
+ * if (error instanceof RateLimitError) {
96
+ * console.error('Rate limit exceeded');
97
+ * console.log(`Limit: ${error.limit}`);
98
+ * console.log(`Remaining: ${error.remaining}`);
99
+ * console.log(`Resets at: ${error.resetTime}`);
100
+ * }
101
+ * }
102
+ * ```
103
+ */
104
+ declare class RateLimitError extends SmoothSendError {
105
+ limit: number;
106
+ remaining: number;
107
+ resetTime: string;
108
+ /**
109
+ * Creates a new RateLimitError
110
+ *
111
+ * @param message - Human-readable error message
112
+ * @param limit - Maximum requests allowed per period
113
+ * @param remaining - Remaining requests in current period
114
+ * @param resetTime - When the rate limit resets (ISO 8601 timestamp)
115
+ */
116
+ constructor(message: string, limit: number, remaining: number, resetTime: string);
117
+ }
118
+ /**
119
+ * Validation error - thrown when request parameters are invalid
120
+ *
121
+ * @remarks
122
+ * HTTP Status Code: 400
123
+ * Contains field name that failed validation
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * try {
128
+ * await sdk.transfer(request, wallet);
129
+ * } catch (error) {
130
+ * if (error instanceof ValidationError) {
131
+ * console.error(`Invalid ${error.field}:`, error.message);
132
+ * }
133
+ * }
134
+ * ```
135
+ */
136
+ declare class ValidationError extends SmoothSendError {
137
+ field: string;
138
+ /**
139
+ * Creates a new ValidationError
140
+ *
141
+ * @param message - Human-readable error message
142
+ * @param field - Name of the field that failed validation
143
+ * @param details - Additional error details
144
+ */
145
+ constructor(message: string, field: string, details?: any);
146
+ }
147
+ /**
148
+ * Network error - thrown when network connectivity issues occur
149
+ *
150
+ * @remarks
151
+ * HTTP Status Code: 0 (no HTTP response)
152
+ * Indicates network connectivity problems
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * try {
157
+ * await sdk.transfer(request, wallet);
158
+ * } catch (error) {
159
+ * if (error instanceof NetworkError) {
160
+ * console.error('Network error:', error.message);
161
+ * console.log('Original error:', error.originalError);
162
+ * }
163
+ * }
164
+ * ```
165
+ */
166
+ declare class NetworkError extends SmoothSendError {
167
+ originalError?: Error | undefined;
168
+ /**
169
+ * Creates a new NetworkError
170
+ *
171
+ * @param message - Human-readable error message
172
+ * @param originalError - Original error that caused the network failure
173
+ */
174
+ constructor(message: string, originalError?: Error | undefined);
175
+ }
176
+ /**
177
+ * Helper function to create appropriate error from HTTP response
178
+ *
179
+ * @remarks
180
+ * Parses HTTP error response and creates typed error object
181
+ * Used internally by HTTP client
182
+ *
183
+ * @param statusCode - HTTP status code
184
+ * @param errorData - Error response data from API
185
+ * @param defaultMessage - Default message if none provided in response
186
+ * @returns Typed error object
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const error = createErrorFromResponse(401, {
191
+ * error: 'Invalid API key',
192
+ * details: { field: 'apiKey' }
193
+ * });
194
+ * throw error;
195
+ * ```
196
+ */
197
+ declare function createErrorFromResponse(statusCode: number, errorData: any, defaultMessage?: string): SmoothSendError;
198
+ /**
199
+ * Helper function to create network error from exception
200
+ *
201
+ * @remarks
202
+ * Wraps generic exceptions in NetworkError for consistent error handling
203
+ * Used internally by HTTP client
204
+ *
205
+ * @param error - Original error or exception
206
+ * @returns NetworkError instance
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * try {
211
+ * await fetch(url);
212
+ * } catch (error) {
213
+ * throw createNetworkError(error);
214
+ * }
215
+ * ```
216
+ */
217
+ declare function createNetworkError(error: any): NetworkError;
218
+
219
+ /**
220
+ * Supported blockchain chains in the SmoothSend SDK
221
+ *
222
+ * @remarks
223
+ * - `avalanche`: Avalanche C-Chain (EVM-compatible)
224
+ * - `aptos-testnet`: Aptos testnet
225
+ * - `aptos-mainnet`: Aptos mainnet
226
+ */
227
+ type SupportedChain = 'avalanche' | 'aptos-testnet' | 'aptos-mainnet';
228
+ /**
229
+ * Chain ecosystem types for routing to correct relayers
230
+ *
231
+ * @remarks
232
+ * - `evm`: Ethereum Virtual Machine compatible chains (Avalanche, Base, Arbitrum, etc.)
233
+ * - `aptos`: Aptos blockchain ecosystem
234
+ */
235
+ type ChainEcosystem = 'evm' | 'aptos';
236
+ /**
237
+ * Mapping of supported chains to their respective ecosystems
238
+ * Used internally for adapter selection and routing
239
+ */
240
+ declare const CHAIN_ECOSYSTEM_MAP: Record<SupportedChain, ChainEcosystem>;
241
+ /**
242
+ * Base success response structure
243
+ * All successful API responses extend this interface
244
+ */
245
+ interface SuccessResponse {
246
+ /** Indicates the request was successful */
247
+ success: true;
248
+ }
249
+ /**
250
+ * Base error response structure
251
+ * All error API responses extend this interface
252
+ */
253
+ interface ErrorResponse {
254
+ /** Indicates the request failed */
255
+ success: false;
256
+ /** Human-readable error message */
257
+ error: string;
258
+ /** Additional error details or validation errors */
259
+ details?: string[];
260
+ /** Unique request identifier for debugging */
261
+ requestId?: string;
262
+ }
263
+ /**
264
+ * Chain information structure
265
+ * Contains metadata about a supported blockchain
266
+ */
267
+ interface ChainInfo {
268
+ /** Chain identifier (e.g., 'aptos-testnet') */
269
+ name: string;
270
+ /** Human-readable chain name */
271
+ displayName: string;
272
+ /** Numeric chain ID */
273
+ chainId: number;
274
+ /** Block explorer base URL */
275
+ explorerUrl: string;
276
+ /** List of supported token symbols */
277
+ tokens: string[];
278
+ }
279
+ /**
280
+ * Token information structure
281
+ * Contains metadata about a supported token
282
+ */
283
+ interface TokenInfo {
284
+ /** Token symbol (e.g., 'USDC') */
285
+ symbol: string;
286
+ /** Token contract address */
287
+ address: string;
288
+ /** Number of decimal places */
289
+ decimals: number;
290
+ /** Full token name */
291
+ name: string;
292
+ }
293
+ /**
294
+ * Chain configuration structure
295
+ * Complete configuration for a blockchain network
296
+ */
297
+ interface ChainConfig {
298
+ /** Chain identifier */
299
+ name: string;
300
+ /** Human-readable chain name */
301
+ displayName: string;
302
+ /** Numeric chain ID */
303
+ chainId: number;
304
+ /** RPC endpoint URL */
305
+ rpcUrl: string;
306
+ /** Relayer service URL */
307
+ relayerUrl: string;
308
+ /** Block explorer base URL */
309
+ explorerUrl: string;
310
+ /** List of supported token symbols */
311
+ tokens: string[];
312
+ /** Native currency information */
313
+ nativeCurrency: {
314
+ /** Currency name */
315
+ name: string;
316
+ /** Currency symbol */
317
+ symbol: string;
318
+ /** Number of decimal places */
319
+ decimals: number;
320
+ };
321
+ }
322
+ /**
323
+ * Transfer request parameters
324
+ * Used to initiate a gasless token transfer
325
+ *
326
+ * @example
327
+ * ```typescript
328
+ * const request: TransferRequest = {
329
+ * from: '0x123...',
330
+ * to: '0x456...',
331
+ * token: 'USDC',
332
+ * amount: '1000000', // 1 USDC (6 decimals)
333
+ * chain: 'aptos-testnet'
334
+ * };
335
+ * ```
336
+ */
337
+ interface TransferRequest {
338
+ /** Sender's wallet address */
339
+ from: string;
340
+ /** Recipient's wallet address */
341
+ to: string;
342
+ /** Token symbol or contract address */
343
+ token: string;
344
+ /** Amount in smallest unit (wei, octas, etc.) */
345
+ amount: string;
346
+ /** Target blockchain */
347
+ chain: SupportedChain;
348
+ }
349
+ /**
350
+ * Transfer quote response from API
351
+ * Contains fee information for a transfer
352
+ */
353
+ interface TransferQuoteResponse extends SuccessResponse {
354
+ /** Chain identifier */
355
+ chainName: string;
356
+ /** Token symbol */
357
+ token: string;
358
+ /** Transfer amount */
359
+ amount: string;
360
+ /** Relayer fee amount */
361
+ relayerFee: string;
362
+ /** Total amount (amount + fee) */
363
+ total: string;
364
+ /** Fee as percentage of amount */
365
+ feePercentage: number;
366
+ /** Token contract address */
367
+ contractAddress: string;
368
+ }
369
+ /**
370
+ * Fee estimate response from proxy worker
371
+ * Contains detailed fee information for a transfer
372
+ *
373
+ * @remarks
374
+ * Returned by `estimateFee()` method
375
+ */
376
+ interface FeeEstimate {
377
+ /** Fee charged by relayer in token units */
378
+ relayerFee: string;
379
+ /** Fee in USD for reference */
380
+ feeInUSD: string;
381
+ /** Full coin type identifier (e.g., '0x1::aptos_coin::AptosCoin') */
382
+ coinType: string;
383
+ /** Estimated gas units */
384
+ estimatedGas: string;
385
+ /** Network (testnet or mainnet) */
386
+ network: 'testnet' | 'mainnet';
387
+ }
388
+ /**
389
+ * Transfer quote information
390
+ * Contains fee breakdown and contract details
391
+ */
392
+ interface TransferQuote {
393
+ /** Transfer amount */
394
+ amount: string;
395
+ /** Relayer fee amount */
396
+ relayerFee: string;
397
+ /** Total amount (amount + fee) */
398
+ total: string;
399
+ /** Fee as percentage of amount */
400
+ feePercentage: number;
401
+ /** Token contract address */
402
+ contractAddress: string;
403
+ /** Aptos-specific transaction data (optional for backward compatibility) */
404
+ aptosTransactionData?: any;
405
+ }
406
+ /**
407
+ * Relay transfer response from API
408
+ * Contains transaction execution details
409
+ */
410
+ interface RelayTransferResponse extends SuccessResponse {
411
+ /** Unique transfer identifier */
412
+ transferId: string;
413
+ /** Transaction hash */
414
+ txHash: string;
415
+ /** Block number where transaction was included */
416
+ blockNumber: number;
417
+ /** Gas units consumed */
418
+ gasUsed: string;
419
+ /** Block explorer URL for transaction */
420
+ explorerUrl: string;
421
+ /** Fee paid for the transfer */
422
+ fee: string;
423
+ /** Execution time in milliseconds */
424
+ executionTime: number;
425
+ }
426
+ /**
427
+ * Transfer result structure
428
+ * Contains complete information about a transfer execution
429
+ *
430
+ * @remarks
431
+ * Returned by `executeGaslessTransfer()` and `transfer()` methods
432
+ *
433
+ * @example
434
+ * ```typescript
435
+ * const result = await sdk.executeGaslessTransfer(signedData);
436
+ * console.log(`Transaction: ${result.txHash}`);
437
+ * console.log(`Explorer: ${result.explorerUrl}`);
438
+ * console.log(`Rate limit remaining: ${result.metadata?.rateLimit.remaining}`);
439
+ * ```
440
+ */
441
+ interface TransferResult {
442
+ /** Indicates if transfer was successful */
443
+ success: boolean;
444
+ /** Transaction hash */
445
+ txHash: string;
446
+ /** Block number where transaction was included */
447
+ blockNumber?: number;
448
+ /** Gas units consumed */
449
+ gasUsed?: string;
450
+ /** Unique transfer identifier */
451
+ transferId?: string;
452
+ /** Block explorer URL for transaction */
453
+ explorerUrl?: string;
454
+ /** Fee paid for the transfer */
455
+ fee?: string;
456
+ /** Execution time in milliseconds */
457
+ executionTime?: number;
458
+ /** Address that paid the gas fee (Aptos-specific) */
459
+ gasFeePaidBy?: string;
460
+ /** Whether user paid in APT (Aptos-specific) */
461
+ userPaidAPT?: boolean;
462
+ /** Transparency information (Aptos-specific) */
463
+ transparency?: string;
464
+ /** VM execution status (Aptos-specific) */
465
+ vmStatus?: string;
466
+ /** Sender address (Aptos-specific) */
467
+ sender?: string;
468
+ /** Chain identifier (Aptos-specific) */
469
+ chain?: string;
470
+ /** Relayer fee amount (Aptos-specific) */
471
+ relayerFee?: string;
472
+ /** Additional message or status information */
473
+ message?: string;
474
+ /** Usage metadata from proxy worker (v2) */
475
+ metadata?: UsageMetadata;
476
+ }
477
+ /**
478
+ * Batch transfer request parameters
479
+ * Used to execute multiple transfers in a single transaction
480
+ *
481
+ * @remarks
482
+ * Batch transfers are more gas-efficient than individual transfers
483
+ */
484
+ interface BatchTransferRequest {
485
+ /** Array of transfer requests to execute */
486
+ transfers: TransferRequest[];
487
+ /** Target blockchain */
488
+ chain: SupportedChain;
489
+ }
490
+ /**
491
+ * EVM transfer data structure
492
+ * Contains signed transfer data for EVM-compatible chains
493
+ *
494
+ * @remarks
495
+ * Used for Avalanche and other EVM chains
496
+ */
497
+ interface EVMTransferData {
498
+ /** Chain identifier */
499
+ chainName: string;
500
+ /** Sender address */
501
+ from: string;
502
+ /** Recipient address */
503
+ to: string;
504
+ /** Token symbol */
505
+ tokenSymbol: string;
506
+ /** Transfer amount */
507
+ amount: string;
508
+ /** Relayer fee amount */
509
+ relayerFee: string;
510
+ /** Transaction nonce */
511
+ nonce: string;
512
+ /** Signature deadline timestamp */
513
+ deadline: number;
514
+ /** EIP-712 signature */
515
+ signature: string;
516
+ /** ERC-2612 permit data (optional) */
517
+ permitData?: {
518
+ /** Permit value */
519
+ value: string;
520
+ /** Permit deadline */
521
+ deadline: number;
522
+ /** Signature v component */
523
+ v: number;
524
+ /** Signature r component */
525
+ r: string;
526
+ /** Signature s component */
527
+ s: string;
528
+ };
529
+ }
530
+ /**
531
+ * Legacy type alias for Avalanche transfers
532
+ * @deprecated Use EVMTransferData instead
533
+ */
534
+ type AvalancheTransferData = EVMTransferData;
535
+ /**
536
+ * Aptos transfer data structure
537
+ * Contains serialized transaction data for secure Aptos transfers
538
+ *
539
+ * @remarks
540
+ * Uses serialized transaction approach for enhanced security
541
+ * Transaction must be built and signed by wallet before submission
542
+ *
543
+ * @example
544
+ * ```typescript
545
+ * const aptosData: AptosTransferData = {
546
+ * transactionBytes: Array.from(signedTx.transactionBytes),
547
+ * authenticatorBytes: Array.from(signedTx.authenticatorBytes)
548
+ * };
549
+ * ```
550
+ */
551
+ interface AptosTransferData {
552
+ /** Serialized SimpleTransaction as byte array */
553
+ transactionBytes: number[];
554
+ /** Serialized AccountAuthenticator as byte array */
555
+ authenticatorBytes: number[];
556
+ /** Optional function name for debugging/tracking */
557
+ functionName?: string;
558
+ /** Sender address (optional metadata) */
559
+ fromAddress?: string;
560
+ /** Recipient address (optional metadata) */
561
+ toAddress?: string;
562
+ /** Transfer amount (optional metadata) */
563
+ amount?: string;
564
+ /** Coin type identifier (optional metadata) */
565
+ coinType?: string;
566
+ }
567
+ /**
568
+ * EIP-712 signature data structure
569
+ * Contains typed data for signature verification
570
+ */
571
+ interface SignatureData {
572
+ /** EIP-712 domain separator */
573
+ domain: any;
574
+ /** Type definitions */
575
+ types: any;
576
+ /** Message to sign */
577
+ message: any;
578
+ /** Primary type name */
579
+ primaryType: string;
580
+ /** Enhanced metadata for signature verification */
581
+ metadata?: {
582
+ /** Target chain */
583
+ chain?: SupportedChain;
584
+ /** Sender address */
585
+ fromAddress?: string;
586
+ /** Recipient address */
587
+ toAddress?: string;
588
+ /** Transfer amount */
589
+ amount?: string;
590
+ /** Token symbol */
591
+ token?: string;
592
+ /** Relayer fee */
593
+ relayerFee?: string;
594
+ /** Signature version */
595
+ signatureVersion?: string;
596
+ /** Whether public key is required */
597
+ requiresPublicKey?: boolean;
598
+ /** Verification method */
599
+ verificationMethod?: string;
600
+ };
601
+ }
602
+ /**
603
+ * Signed transfer data for SDK v2
604
+ * Contains serialized transaction bytes for secure Aptos transfers
605
+ *
606
+ * @remarks
607
+ * Used with `executeGaslessTransfer()` method
608
+ * Transaction must be built and signed by wallet before creating this structure
609
+ *
610
+ * @example
611
+ * ```typescript
612
+ * const signedData: SignedTransferData = {
613
+ * transactionBytes: Array.from(signedTx.transactionBytes),
614
+ * authenticatorBytes: Array.from(signedTx.authenticatorBytes),
615
+ * chain: 'aptos-testnet',
616
+ * network: 'testnet'
617
+ * };
618
+ * const result = await sdk.executeGaslessTransfer(signedData);
619
+ * ```
620
+ */
621
+ interface SignedTransferData {
622
+ /** Serialized transaction (Aptos) */
623
+ transactionBytes: number[];
624
+ /** Serialized authenticator (Aptos) */
625
+ authenticatorBytes: number[];
626
+ /** Target blockchain */
627
+ chain: SupportedChain;
628
+ /** Optional network override (testnet or mainnet) */
629
+ network?: 'testnet' | 'mainnet';
630
+ }
631
+ /**
632
+ * Token balance information
633
+ * Contains balance and metadata for a specific token
634
+ */
635
+ interface TokenBalance {
636
+ /** Token symbol or address */
637
+ token: string;
638
+ /** Balance in smallest unit */
639
+ balance: string;
640
+ /** Number of decimal places */
641
+ decimals: number;
642
+ /** Token symbol */
643
+ symbol: string;
644
+ /** Full token name (optional) */
645
+ name?: string;
646
+ }
647
+ /**
648
+ * Transfer quote request parameters
649
+ * Used to request fee estimate from API
650
+ */
651
+ interface TransferQuoteRequest {
652
+ /** Chain identifier */
653
+ chainName: string;
654
+ /** Token symbol */
655
+ token: string;
656
+ /** Transfer amount */
657
+ amount: string;
658
+ }
659
+ /**
660
+ * Prepare signature request parameters
661
+ * Used to get typed data for EIP-712 signature
662
+ */
663
+ interface PrepareSignatureRequest {
664
+ /** Chain identifier */
665
+ chainName: string;
666
+ /** Sender address */
667
+ from: string;
668
+ /** Recipient address */
669
+ to: string;
670
+ /** Token symbol */
671
+ tokenSymbol: string;
672
+ /** Transfer amount */
673
+ amount: string;
674
+ /** Relayer fee amount */
675
+ relayerFee: string;
676
+ /** Transaction nonce */
677
+ nonce: string;
678
+ /** Signature deadline timestamp */
679
+ deadline: number;
680
+ }
681
+ /**
682
+ * Relay transfer request parameters
683
+ * Used to submit signed transfer to relayer
684
+ */
685
+ interface RelayTransferRequest {
686
+ /** Chain identifier */
687
+ chainName: string;
688
+ /** Sender address */
689
+ from: string;
690
+ /** Recipient address */
691
+ to: string;
692
+ /** Token symbol */
693
+ tokenSymbol: string;
694
+ /** Transfer amount */
695
+ amount: string;
696
+ /** Relayer fee amount */
697
+ relayerFee: string;
698
+ /** Transaction nonce */
699
+ nonce: string;
700
+ /** Signature deadline timestamp */
701
+ deadline: number;
702
+ /** EIP-712 signature */
703
+ signature: string;
704
+ /** ERC-2612 permit data (optional) */
705
+ permitData?: PermitData;
706
+ }
707
+ /**
708
+ * Batch relay transfer request parameters
709
+ * Used to submit multiple signed transfers in one transaction
710
+ */
711
+ interface BatchRelayTransferRequest {
712
+ /** Chain identifier */
713
+ chainName: string;
714
+ /** Array of transfer requests */
715
+ transfers: RelayTransferRequest[];
716
+ }
717
+ /**
718
+ * Gas estimate request parameters
719
+ * Used to estimate gas cost for transfers
720
+ */
721
+ interface EstimateGasRequest {
722
+ /** Chain identifier */
723
+ chainName: string;
724
+ /** Array of transfer data */
725
+ transfers: TransferData[];
726
+ }
727
+ /**
728
+ * Transfer data structure
729
+ * Contains complete transfer information including signature
730
+ */
731
+ interface TransferData {
732
+ /** Sender address */
733
+ from: string;
734
+ /** Recipient address */
735
+ to: string;
736
+ /** Token symbol or address */
737
+ token: string;
738
+ /** Transfer amount */
739
+ amount: string;
740
+ /** Relayer fee amount */
741
+ relayerFee: string;
742
+ /** Transaction nonce */
743
+ nonce: string;
744
+ /** Signature deadline timestamp */
745
+ deadline: number;
746
+ /** EIP-712 signature */
747
+ signature: string;
748
+ /** ERC-2612 permit data (optional) */
749
+ permitData?: PermitData;
750
+ }
751
+ /**
752
+ * ERC-2612 permit data structure
753
+ * Used for gasless token approvals
754
+ */
755
+ interface PermitData {
756
+ /** Permit value (amount) */
757
+ value: string;
758
+ /** Permit deadline timestamp */
759
+ deadline: number;
760
+ /** Signature v component */
761
+ v: number;
762
+ /** Signature r component */
763
+ r: string;
764
+ /** Signature s component */
765
+ s: string;
766
+ }
767
+ /**
768
+ * Prepare signature response from API
769
+ * Contains EIP-712 typed data for signing
770
+ */
771
+ interface PrepareSignatureResponse extends SuccessResponse {
772
+ /** EIP-712 typed data structure */
773
+ typedData: any;
774
+ /** Keccak256 hash of the message */
775
+ messageHash: string;
776
+ /** Human-readable message */
777
+ message: string;
778
+ }
779
+ /**
780
+ * Gas estimate response from API
781
+ * Contains estimated gas cost for transfers
782
+ */
783
+ interface GasEstimateResponse extends SuccessResponse {
784
+ /** Chain identifier */
785
+ chainName: string;
786
+ /** Estimated gas units */
787
+ gasEstimate: string;
788
+ /** Current gas price */
789
+ gasPrice: string;
790
+ /** Estimated cost in native currency */
791
+ estimatedCost: string;
792
+ /** Number of transfers in batch */
793
+ transferCount: number;
794
+ }
795
+ /**
796
+ * Health check response
797
+ * Contains service health status information
798
+ *
799
+ * @remarks
800
+ * Returned by `getHealth()` and `getChainHealth()` methods
801
+ */
802
+ interface HealthResponse extends SuccessResponse {
803
+ /** Service status (e.g., 'healthy', 'degraded') */
804
+ status: string;
805
+ /** Response timestamp (ISO 8601) */
806
+ timestamp: string;
807
+ /** Service version */
808
+ version: string;
809
+ }
810
+ /**
811
+ * Domain separator response from API
812
+ * Contains EIP-712 domain separator for a chain
813
+ */
814
+ interface DomainSeparatorResponse extends SuccessResponse {
815
+ /** Chain identifier */
816
+ chainName: string;
817
+ /** EIP-712 domain separator hash */
818
+ domainSeparator: string;
819
+ }
820
+ /**
821
+ * Transfer status response from API
822
+ * Contains execution status of a transfer
823
+ */
824
+ interface TransferStatusResponse extends SuccessResponse {
825
+ /** Chain identifier */
826
+ chainName: string;
827
+ /** Transfer transaction hash */
828
+ transferHash: string;
829
+ /** Whether transfer has been executed */
830
+ executed: boolean;
831
+ }
832
+ /**
833
+ * Aptos-specific error codes
834
+ * Used for detailed error handling in Aptos adapter
835
+ *
836
+ * @remarks
837
+ * Error codes are prefixed with APTOS_ for easy identification
838
+ */
839
+ declare const APTOS_ERROR_CODES: {
840
+ /** Missing signature in request */
841
+ readonly MISSING_SIGNATURE: "APTOS_MISSING_SIGNATURE";
842
+ /** Missing public key for verification */
843
+ readonly MISSING_PUBLIC_KEY: "APTOS_MISSING_PUBLIC_KEY";
844
+ /** Invalid signature format */
845
+ readonly INVALID_SIGNATURE_FORMAT: "APTOS_INVALID_SIGNATURE_FORMAT";
846
+ /** Invalid public key format */
847
+ readonly INVALID_PUBLIC_KEY_FORMAT: "APTOS_INVALID_PUBLIC_KEY_FORMAT";
848
+ /** Address doesn't match public key */
849
+ readonly ADDRESS_MISMATCH: "APTOS_ADDRESS_MISMATCH";
850
+ /** Signature verification failed */
851
+ readonly SIGNATURE_VERIFICATION_FAILED: "APTOS_SIGNATURE_VERIFICATION_FAILED";
852
+ /** Missing transaction data */
853
+ readonly MISSING_TRANSACTION_DATA: "APTOS_MISSING_TRANSACTION_DATA";
854
+ /** Invalid transaction format */
855
+ readonly INVALID_TRANSACTION_FORMAT: "APTOS_INVALID_TRANSACTION_FORMAT";
856
+ /** Empty address provided */
857
+ readonly EMPTY_ADDRESS: "APTOS_EMPTY_ADDRESS";
858
+ /** Invalid address format */
859
+ readonly INVALID_ADDRESS_FORMAT: "APTOS_INVALID_ADDRESS_FORMAT";
860
+ /** Error fetching quote */
861
+ readonly QUOTE_ERROR: "APTOS_QUOTE_ERROR";
862
+ /** Error executing transfer */
863
+ readonly EXECUTE_ERROR: "APTOS_EXECUTE_ERROR";
864
+ /** Error fetching balance */
865
+ readonly BALANCE_ERROR: "APTOS_BALANCE_ERROR";
866
+ /** Error fetching token info */
867
+ readonly TOKEN_INFO_ERROR: "APTOS_TOKEN_INFO_ERROR";
868
+ /** Error checking status */
869
+ readonly STATUS_ERROR: "APTOS_STATUS_ERROR";
870
+ /** Error calling Move function */
871
+ readonly MOVE_CALL_ERROR: "APTOS_MOVE_CALL_ERROR";
872
+ /** Unsupported token */
873
+ readonly UNSUPPORTED_TOKEN: "APTOS_UNSUPPORTED_TOKEN";
874
+ };
875
+ /**
876
+ * Type for Aptos error codes
877
+ * Ensures type safety when using error codes
878
+ */
879
+ type AptosErrorCode = typeof APTOS_ERROR_CODES[keyof typeof APTOS_ERROR_CODES];
880
+ /**
881
+ * Generic API response structure
882
+ * Used for all API responses with optional data payload
883
+ *
884
+ * @typeParam T - Type of the response data
885
+ *
886
+ * @example
887
+ * ```typescript
888
+ * const response: ApiResponse<TransferResult> = await api.transfer(data);
889
+ * if (response.success && response.data) {
890
+ * console.log('Transfer successful:', response.data.txHash);
891
+ * }
892
+ * ```
893
+ */
894
+ interface ApiResponse<T = any> {
895
+ /** Indicates if request was successful */
896
+ success: boolean;
897
+ /** Response data (present on success) */
898
+ data?: T;
899
+ /** Error message (present on failure) */
900
+ error?: string;
901
+ /** Additional error details */
902
+ details?: string[];
903
+ /** Unique request identifier */
904
+ requestId?: string;
905
+ /** Error code for programmatic handling */
906
+ errorCode?: string;
907
+ /** Chain where request was made */
908
+ chain?: SupportedChain;
909
+ /** Response timestamp (ISO 8601) */
910
+ timestamp?: string;
911
+ /** Usage metadata from proxy worker (v2) */
912
+ metadata?: UsageMetadata;
913
+ }
914
+ /**
915
+ * SDK configuration for v2 - Proxy-based architecture
916
+ *
917
+ * @remarks
918
+ * All requests route through proxy.smoothsend.xyz with API key authentication
919
+ *
920
+ * @example
921
+ * ```typescript
922
+ * const config: SmoothSendConfig = {
923
+ * apiKey: 'no_gas_abc123...',
924
+ * network: 'testnet',
925
+ * timeout: 30000,
926
+ * retries: 3
927
+ * };
928
+ * const sdk = new SmoothSendSDK(config);
929
+ * ```
930
+ */
931
+ interface SmoothSendConfig {
932
+ /** API key with no_gas_ prefix for authentication (required) */
933
+ apiKey: string;
934
+ /** Network to use: testnet or mainnet (default: testnet) */
935
+ network?: 'testnet' | 'mainnet';
936
+ /** Request timeout in milliseconds (default: 30000) */
937
+ timeout?: number;
938
+ /** Maximum retry attempts for failed requests (default: 3) */
939
+ retries?: number;
940
+ /** Additional headers to include in requests */
941
+ customHeaders?: Record<string, string>;
942
+ }
943
+ /**
944
+ * Usage metadata from proxy worker response headers
945
+ * Contains rate limiting and usage tracking information
946
+ *
947
+ * @remarks
948
+ * Attached to all transfer results and available via `getUsageStats()`
949
+ *
950
+ * @example
951
+ * ```typescript
952
+ * const result = await sdk.transfer(request, wallet);
953
+ * console.log('Rate limit:', result.metadata?.rateLimit);
954
+ * console.log('Monthly usage:', result.metadata?.monthly);
955
+ *
956
+ * // Check if approaching limits
957
+ * if (parseInt(result.metadata.rateLimit.remaining) < 2) {
958
+ * console.warn('Approaching rate limit!');
959
+ * }
960
+ * ```
961
+ */
962
+ interface UsageMetadata {
963
+ /** Rate limit information (per minute) */
964
+ rateLimit: {
965
+ /** Maximum requests per minute */
966
+ limit: string;
967
+ /** Remaining requests this minute */
968
+ remaining: string;
969
+ /** When rate limit resets (ISO 8601 timestamp) */
970
+ reset: string;
971
+ };
972
+ /** Monthly usage information */
973
+ monthly: {
974
+ /** Total monthly request limit */
975
+ limit: string;
976
+ /** Requests used this month */
977
+ usage: string;
978
+ /** Remaining requests this month */
979
+ remaining: string;
980
+ };
981
+ /** Unique request identifier for debugging */
982
+ requestId: string;
983
+ }
984
+ /**
985
+ * Transfer event types
986
+ * Emitted during transfer lifecycle for monitoring and debugging
987
+ */
988
+ interface TransferEvent {
989
+ /** Event type */
990
+ type: 'transfer_initiated' | 'transfer_signed' | 'transfer_submitted' | 'transfer_confirmed' | 'transfer_failed';
991
+ /** Event data (varies by type) */
992
+ data: any;
993
+ /** Event timestamp (Unix milliseconds) */
994
+ timestamp: number;
995
+ /** Chain where event occurred */
996
+ chain: SupportedChain;
997
+ }
998
+ /**
999
+ * Event listener callback function
1000
+ * Called when transfer events are emitted
1001
+ *
1002
+ * @param event - Transfer event object
1003
+ *
1004
+ * @example
1005
+ * ```typescript
1006
+ * const listener: EventListener = (event) => {
1007
+ * console.log(`Event: ${event.type} on ${event.chain}`);
1008
+ * };
1009
+ * sdk.addEventListener(listener);
1010
+ * ```
1011
+ */
1012
+ type EventListener = (event: TransferEvent) => void;
1013
+ /**
1014
+ * Chain Adapter Interface - v2 Proxy Architecture
1015
+ *
1016
+ * @remarks
1017
+ * All adapters route requests through proxy.smoothsend.xyz with API key authentication.
1018
+ * The proxy handles relayer URL routing, so adapters no longer need direct relayer configuration.
1019
+ *
1020
+ * Key changes from v1:
1021
+ * - Removed `config` property (relayer URLs handled by proxy)
1022
+ * - Simplified to core methods: estimateFee, executeGaslessTransfer
1023
+ * - Removed getQuote, prepareTransfer, getNonce, getTokenInfo (not needed for proxy flow)
1024
+ * - Network parameter (testnet/mainnet) passed via HTTP headers, not method parameters
1025
+ * - Client-side validation methods remain for address and amount validation
1026
+ *
1027
+ * Design rationale:
1028
+ * - Consistent interface across all chains
1029
+ * - Minimal surface area - only essential methods
1030
+ * - Async by default for all I/O operations
1031
+ * - Client-side validation done locally without network calls
1032
+ * - Wallet libraries handle balance queries and transaction building
1033
+ *
1034
+ * @example
1035
+ * ```typescript
1036
+ * class MyChainAdapter implements IChainAdapter {
1037
+ * readonly chain: SupportedChain = 'aptos-testnet';
1038
+ *
1039
+ * async estimateFee(request: TransferRequest): Promise<FeeEstimate> {
1040
+ * // Implementation
1041
+ * }
1042
+ *
1043
+ * async executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult> {
1044
+ * // Implementation
1045
+ * }
1046
+ *
1047
+ * // ... other methods
1048
+ * }
1049
+ * ```
1050
+ */
1051
+ interface IChainAdapter {
1052
+ /** Chain identifier this adapter handles */
1053
+ readonly chain: SupportedChain;
1054
+ /**
1055
+ * Estimate fee for a transfer
1056
+ *
1057
+ * @param request - Transfer request parameters
1058
+ * @returns Fee estimate with relayer fee and gas information
1059
+ * @throws {ValidationError} If request parameters are invalid
1060
+ * @throws {NetworkError} If unable to reach proxy/relayer
1061
+ *
1062
+ * @example
1063
+ * ```typescript
1064
+ * const estimate = await adapter.estimateFee({
1065
+ * from: '0x123...',
1066
+ * to: '0x456...',
1067
+ * token: 'USDC',
1068
+ * amount: '1000000',
1069
+ * chain: 'aptos-testnet'
1070
+ * });
1071
+ * console.log('Fee:', estimate.relayerFee);
1072
+ * ```
1073
+ */
1074
+ estimateFee(request: TransferRequest): Promise<FeeEstimate>;
1075
+ /**
1076
+ * Execute a gasless transfer with signed transaction data
1077
+ *
1078
+ * @param signedData - Signed transfer data with serialized transaction
1079
+ * @returns Transfer result with transaction hash and metadata
1080
+ * @throws {AuthenticationError} If API key is invalid
1081
+ * @throws {RateLimitError} If rate limit is exceeded
1082
+ * @throws {ValidationError} If signed data is invalid
1083
+ * @throws {NetworkError} If unable to reach proxy/relayer
1084
+ *
1085
+ * @example
1086
+ * ```typescript
1087
+ * const result = await adapter.executeGaslessTransfer({
1088
+ * transactionBytes: [1, 2, 3, ...],
1089
+ * authenticatorBytes: [4, 5, 6, ...],
1090
+ * chain: 'aptos-testnet',
1091
+ * network: 'testnet'
1092
+ * });
1093
+ * console.log('Transaction:', result.txHash);
1094
+ * ```
1095
+ */
1096
+ executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
1097
+ /**
1098
+ * Get transaction status by hash
1099
+ *
1100
+ * @param txHash - Transaction hash to query
1101
+ * @returns Transaction status information
1102
+ * @throws {ValidationError} If transaction hash is invalid
1103
+ * @throws {NetworkError} If unable to reach proxy/relayer
1104
+ *
1105
+ * @example
1106
+ * ```typescript
1107
+ * const status = await adapter.getTransactionStatus('0xabc123...');
1108
+ * console.log('Status:', status);
1109
+ * ```
1110
+ */
1111
+ getTransactionStatus(txHash: string): Promise<any>;
1112
+ /**
1113
+ * Check health status of the chain's relayer
1114
+ *
1115
+ * @returns Health response with status and version
1116
+ * @throws {NetworkError} If unable to reach proxy/relayer
1117
+ *
1118
+ * @example
1119
+ * ```typescript
1120
+ * const health = await adapter.getHealth();
1121
+ * console.log('Status:', health.status);
1122
+ * ```
1123
+ */
1124
+ getHealth(): Promise<HealthResponse>;
1125
+ /**
1126
+ * Validate address format (client-side, no network call)
1127
+ *
1128
+ * @param address - Address to validate
1129
+ * @returns true if address format is valid, false otherwise
1130
+ *
1131
+ * @example
1132
+ * ```typescript
1133
+ * const isValid = adapter.validateAddress('0x123...');
1134
+ * if (!isValid) {
1135
+ * console.error('Invalid address format');
1136
+ * }
1137
+ * ```
1138
+ */
1139
+ validateAddress(address: string): boolean;
1140
+ /**
1141
+ * Validate amount format (client-side, no network call)
1142
+ *
1143
+ * @param amount - Amount to validate (in smallest unit)
1144
+ * @returns true if amount format is valid, false otherwise
1145
+ *
1146
+ * @example
1147
+ * ```typescript
1148
+ * const isValid = adapter.validateAmount('1000000');
1149
+ * if (!isValid) {
1150
+ * console.error('Invalid amount format');
1151
+ * }
1152
+ * ```
1153
+ */
1154
+ validateAmount(amount: string): boolean;
1155
+ }
1156
+
1157
+ declare class SmoothSendSDK {
1158
+ private adapters;
1159
+ private eventListeners;
1160
+ private config;
1161
+ private keyType;
1162
+ private hasWarnedAboutSecretKey;
1163
+ constructor(config: SmoothSendConfig);
1164
+ /**
1165
+ * Detect key type from API key prefix
1166
+ * Supports pk_nogas_* (public), sk_nogas_* (secret), and no_gas_* (legacy)
1167
+ */
1168
+ private detectKeyType;
1169
+ /**
1170
+ * Check if running in browser environment
1171
+ * Used for conditional warnings and Origin header logic
1172
+ */
1173
+ private isBrowserEnvironment;
1174
+ /**
1175
+ * Warn if secret key is used in browser environment
1176
+ * Only warns once per SDK instance
1177
+ */
1178
+ private warnIfSecretKeyInBrowser;
1179
+ /**
1180
+ * Determine if Origin header should be included in requests
1181
+ * Include Origin header only for public keys in browser environment
1182
+ */
1183
+ private shouldIncludeOrigin;
1184
+ /**
1185
+ * Get or create adapter for a specific chain on-demand
1186
+ */
1187
+ private getOrCreateAdapter;
1188
+ addEventListener(listener: EventListener): void;
1189
+ removeEventListener(listener: EventListener): void;
1190
+ private emitEvent;
1191
+ estimateFee(request: TransferRequest): Promise<FeeEstimate & {
1192
+ metadata?: UsageMetadata;
1193
+ }>;
1194
+ executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
1195
+ /**
1196
+ * Convenience method for complete transfer flow
1197
+ * Combines estimateFee and executeGaslessTransfer into a single call
1198
+ *
1199
+ * @param request Transfer request with from, to, token, amount, chain
1200
+ * @param wallet Wallet instance that can build and sign transactions
1201
+ * @returns Transfer result with transaction hash and usage metadata
1202
+ *
1203
+ * Note: The wallet parameter should have methods:
1204
+ * - buildTransaction(params): Build transaction from parameters
1205
+ * - signTransaction(transaction): Sign and serialize transaction
1206
+ *
1207
+ * The wallet's signTransaction should return an object with:
1208
+ * - transactionBytes: number[] - Serialized transaction
1209
+ * - authenticatorBytes: number[] - Serialized authenticator
1210
+ */
1211
+ transfer(request: TransferRequest, wallet: {
1212
+ buildTransaction: (params: any) => Promise<any>;
1213
+ signTransaction: (transaction: any) => Promise<{
1214
+ transactionBytes: number[];
1215
+ authenticatorBytes: number[];
1216
+ }>;
1217
+ }): Promise<TransferResult>;
1218
+ /**
1219
+ * Get transaction status for a specific transaction
1220
+ * Routes through proxy to chain-specific status endpoint
1221
+ *
1222
+ * @param chain Chain where the transaction was executed
1223
+ * @param txHash Transaction hash to query
1224
+ * @returns Transaction status information
1225
+ * @throws SmoothSendError if chain is not supported or status check fails
1226
+ *
1227
+ * @example
1228
+ * ```typescript
1229
+ * const status = await sdk.getTransactionStatus('aptos-testnet', '0x123...');
1230
+ * console.log('Transaction status:', status);
1231
+ * ```
1232
+ */
1233
+ getTransactionStatus(chain: SupportedChain, txHash: string): Promise<any>;
1234
+ validateAddress(chain: SupportedChain, address: string): boolean;
1235
+ validateAmount(chain: SupportedChain, amount: string): boolean;
1236
+ /**
1237
+ * Check proxy worker health status
1238
+ * Routes directly to proxy's /health endpoint (not chain-specific)
1239
+ *
1240
+ * @returns Health response with status, version, and timestamp
1241
+ * @throws NetworkError if proxy is unavailable
1242
+ * @throws SmoothSendError for other errors
1243
+ *
1244
+ * @example
1245
+ * ```typescript
1246
+ * try {
1247
+ * const health = await sdk.getHealth();
1248
+ * console.log('Proxy status:', health.status);
1249
+ * console.log('Version:', health.version);
1250
+ * } catch (error) {
1251
+ * if (error instanceof NetworkError) {
1252
+ * console.error('Proxy unavailable. Please retry later.');
1253
+ * }
1254
+ * }
1255
+ * ```
1256
+ */
1257
+ getHealth(): Promise<HealthResponse>;
1258
+ /**
1259
+ * Get list of supported chains (static list)
1260
+ * For dynamic list from proxy, use getSupportedChainsFromProxy()
1261
+ *
1262
+ * @returns Array of supported chain identifiers
1263
+ *
1264
+ * @example
1265
+ * ```typescript
1266
+ * const chains = sdk.getSupportedChains();
1267
+ * console.log('Supported chains:', chains);
1268
+ * // Output: ['aptos-testnet', 'aptos-mainnet']
1269
+ * ```
1270
+ */
1271
+ getSupportedChains(): SupportedChain[];
1272
+ /**
1273
+ * Get list of supported chains from proxy worker (dynamic)
1274
+ * Queries the proxy for the current list of supported chains
1275
+ *
1276
+ * @returns Promise with array of chain information including status
1277
+ * @throws SmoothSendError if unable to fetch chains from proxy
1278
+ *
1279
+ * @example
1280
+ * ```typescript
1281
+ * const chains = await sdk.getSupportedChainsFromProxy();
1282
+ * chains.forEach(chain => {
1283
+ * console.log(`${chain.name} (${chain.id}): ${chain.status}`);
1284
+ * });
1285
+ * ```
1286
+ */
1287
+ getSupportedChainsFromProxy(): Promise<Array<{
1288
+ id: string;
1289
+ name: string;
1290
+ ecosystem: string;
1291
+ network: string;
1292
+ status: string;
1293
+ }>>;
1294
+ /**
1295
+ * Check if a specific chain is currently supported
1296
+ *
1297
+ * @param chain Chain identifier to check
1298
+ * @returns true if chain is supported, false otherwise
1299
+ *
1300
+ * @example
1301
+ * ```typescript
1302
+ * if (sdk.isChainSupported('aptos-testnet')) {
1303
+ * console.log('Aptos testnet is supported');
1304
+ * } else {
1305
+ * console.log('Chain not supported');
1306
+ * }
1307
+ * ```
1308
+ */
1309
+ isChainSupported(chain: string): boolean;
1310
+ /**
1311
+ * Check health status of a specific chain's relayer
1312
+ * Routes through proxy to chain-specific health endpoint
1313
+ *
1314
+ * @param chain Chain identifier to check
1315
+ * @returns Health response for the specific chain
1316
+ * @throws SmoothSendError if chain is not supported or health check fails
1317
+ *
1318
+ * @example
1319
+ * ```typescript
1320
+ * try {
1321
+ * const health = await sdk.getChainHealth('aptos-testnet');
1322
+ * console.log('Aptos testnet status:', health.status);
1323
+ * } catch (error) {
1324
+ * console.error('Chain health check failed:', error.message);
1325
+ * }
1326
+ * ```
1327
+ */
1328
+ getChainHealth(chain: SupportedChain): Promise<HealthResponse>;
1329
+ /**
1330
+ * Get current usage statistics without making a transfer
1331
+ * Makes a lightweight health check request to retrieve usage metadata
1332
+ *
1333
+ * @returns Usage metadata with rate limit and monthly usage information
1334
+ * @throws Error if unable to retrieve usage stats
1335
+ *
1336
+ * @example
1337
+ * ```typescript
1338
+ * const usage = await sdk.getUsageStats();
1339
+ * console.log('Rate limit:', usage.rateLimit);
1340
+ * console.log('Monthly usage:', usage.monthly);
1341
+ * console.log('Request ID:', usage.requestId);
1342
+ *
1343
+ * // Check if approaching limits
1344
+ * if (parseInt(usage.rateLimit.remaining) < 2) {
1345
+ * console.warn('Approaching rate limit!');
1346
+ * }
1347
+ * ```
1348
+ */
1349
+ getUsageStats(): Promise<UsageMetadata>;
1350
+ /**
1351
+ * Extract request ID from a transfer result for debugging and support
1352
+ *
1353
+ * @param result Transfer result from executeGaslessTransfer or transfer
1354
+ * @returns Request ID if available, undefined otherwise
1355
+ *
1356
+ * @example
1357
+ * ```typescript
1358
+ * const result = await sdk.executeGaslessTransfer(signedData);
1359
+ * const requestId = sdk.getRequestId(result);
1360
+ * if (requestId) {
1361
+ * console.log('Request ID for support:', requestId);
1362
+ * }
1363
+ * ```
1364
+ */
1365
+ getRequestId(result: TransferResult): string | undefined;
1366
+ /**
1367
+ * Check if approaching rate limit based on transfer result metadata
1368
+ *
1369
+ * @param result Transfer result with metadata
1370
+ * @param threshold Percentage threshold (0-100) to consider as "approaching" (default: 20)
1371
+ * @returns true if remaining requests are below threshold percentage
1372
+ *
1373
+ * @example
1374
+ * ```typescript
1375
+ * const result = await sdk.transfer(request, wallet);
1376
+ * if (sdk.isApproachingRateLimit(result)) {
1377
+ * console.warn('Approaching rate limit, consider slowing down requests');
1378
+ * }
1379
+ * ```
1380
+ */
1381
+ isApproachingRateLimit(result: TransferResult, threshold?: number): boolean;
1382
+ /**
1383
+ * Check if approaching monthly usage limit based on transfer result metadata
1384
+ *
1385
+ * @param result Transfer result with metadata
1386
+ * @param threshold Percentage threshold (0-100) to consider as "approaching" (default: 90)
1387
+ * @returns true if monthly usage is above threshold percentage
1388
+ *
1389
+ * @example
1390
+ * ```typescript
1391
+ * const result = await sdk.transfer(request, wallet);
1392
+ * if (sdk.isApproachingMonthlyLimit(result)) {
1393
+ * console.warn('Approaching monthly limit, consider upgrading plan');
1394
+ * }
1395
+ * ```
1396
+ */
1397
+ isApproachingMonthlyLimit(result: TransferResult, threshold?: number): boolean;
1398
+ /**
1399
+ * Check if a chain belongs to a specific ecosystem
1400
+ */
1401
+ getChainEcosystem(chain: SupportedChain): ChainEcosystem;
1402
+ /**
1403
+ * Get list of supported chains (static method)
1404
+ * Can be called without instantiating the SDK
1405
+ *
1406
+ * @returns Array of supported chain identifiers
1407
+ *
1408
+ * @example
1409
+ * ```typescript
1410
+ * const chains = SmoothSendSDK.getSupportedChains();
1411
+ * console.log('Supported chains:', chains);
1412
+ * ```
1413
+ */
1414
+ static getSupportedChains(): SupportedChain[];
1415
+ }
1416
+
1417
+ /**
1418
+ * SmoothSend Transaction Submitter
1419
+ *
1420
+ * A TransactionSubmitter implementation that integrates with the Aptos Wallet Adapter
1421
+ * to enable gasless transactions via SmoothSend's relayer network.
1422
+ *
1423
+ * @example
1424
+ * ```typescript
1425
+ * import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
1426
+ * import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react';
1427
+ *
1428
+ * // Create the transaction submitter
1429
+ * const transactionSubmitter = new SmoothSendTransactionSubmitter({
1430
+ * apiKey: 'pk_nogas_your_api_key_here',
1431
+ * network: 'testnet'
1432
+ * });
1433
+ *
1434
+ * // Use in your wallet provider - that's it!
1435
+ * <AptosWalletAdapterProvider
1436
+ * dappConfig={{
1437
+ * network: Network.TESTNET,
1438
+ * transactionSubmitter: transactionSubmitter
1439
+ * }}
1440
+ * >
1441
+ * <App />
1442
+ * </AptosWalletAdapterProvider>
1443
+ * ```
1444
+ */
1445
+ /**
1446
+ * Minimal type definitions for Aptos SDK compatibility
1447
+ * These match the @aptos-labs/ts-sdk types without requiring it as a dependency
1448
+ */
1449
+ /** Represents an Aptos configuration object */
1450
+ interface AptosConfig {
1451
+ network?: string;
1452
+ fullnode?: string;
1453
+ [key: string]: unknown;
1454
+ }
1455
+ /** Represents a pending transaction response */
1456
+ interface PendingTransactionResponse {
1457
+ hash: string;
1458
+ sender: string;
1459
+ sequence_number: string;
1460
+ max_gas_amount: string;
1461
+ gas_unit_price: string;
1462
+ expiration_timestamp_secs: string;
1463
+ payload: unknown;
1464
+ signature?: unknown;
1465
+ type?: string;
1466
+ }
1467
+ /**
1468
+ * Represents any raw transaction from the Aptos SDK
1469
+ * Compatible with SimpleTransaction and MultiAgentTransaction
1470
+ */
1471
+ interface AnyRawTransaction {
1472
+ rawTransaction: {
1473
+ sender: {
1474
+ bcsToBytes(): Uint8Array;
1475
+ toString(): string;
1476
+ };
1477
+ sequence_number: {
1478
+ toString(): string;
1479
+ };
1480
+ max_gas_amount: {
1481
+ toString(): string;
1482
+ };
1483
+ gas_unit_price: {
1484
+ toString(): string;
1485
+ };
1486
+ expiration_timestamp_secs: {
1487
+ toString(): string;
1488
+ };
1489
+ };
1490
+ bcsToBytes(): Uint8Array;
1491
+ feePayerAddress?: {
1492
+ bcsToBytes(): Uint8Array;
1493
+ };
1494
+ secondarySignerAddresses?: Array<{
1495
+ bcsToBytes(): Uint8Array;
1496
+ }>;
1497
+ }
1498
+ /** Represents an account authenticator from the Aptos SDK */
1499
+ interface AccountAuthenticator {
1500
+ bcsToBytes(): Uint8Array;
1501
+ }
1502
+ /**
1503
+ * Configuration options for SmoothSendTransactionSubmitter
1504
+ */
1505
+ interface SmoothSendTransactionSubmitterConfig {
1506
+ /**
1507
+ * Your SmoothSend API key
1508
+ * - Use `pk_nogas_*` for frontend applications (CORS protected)
1509
+ * - Use `sk_nogas_*` for backend applications only
1510
+ */
1511
+ apiKey: string;
1512
+ /**
1513
+ * Network to use
1514
+ * @default 'testnet'
1515
+ */
1516
+ network?: 'testnet' | 'mainnet';
1517
+ /**
1518
+ * Gateway URL (usually you don't need to change this)
1519
+ * @default 'https://proxy.smoothsend.xyz'
1520
+ */
1521
+ gatewayUrl?: string;
1522
+ /**
1523
+ * Request timeout in milliseconds
1524
+ * @default 30000
1525
+ */
1526
+ timeout?: number;
1527
+ /**
1528
+ * Enable debug logging
1529
+ * @default false
1530
+ */
1531
+ debug?: boolean;
1532
+ }
1533
+ /**
1534
+ * TransactionSubmitter interface compatible with @aptos-labs/ts-sdk v2.x
1535
+ * This interface allows the SmoothSendTransactionSubmitter to work as a drop-in
1536
+ * replacement for the default transaction submitter in the Aptos Wallet Adapter.
1537
+ */
1538
+ interface TransactionSubmitter {
1539
+ submitTransaction(args: {
1540
+ aptosConfig: AptosConfig;
1541
+ transaction: AnyRawTransaction;
1542
+ senderAuthenticator: AccountAuthenticator;
1543
+ feePayerAuthenticator?: AccountAuthenticator;
1544
+ additionalSignersAuthenticators?: Array<AccountAuthenticator>;
1545
+ pluginParams?: Record<string, unknown>;
1546
+ }): Promise<PendingTransactionResponse>;
1547
+ }
1548
+ /**
1549
+ * SmoothSend Transaction Submitter
1550
+ *
1551
+ * Implements the TransactionSubmitter interface to enable gasless transactions
1552
+ * through the Aptos Wallet Adapter. Simply pass this to your AptosWalletAdapterProvider
1553
+ * and all transactions will automatically be submitted as gasless through SmoothSend.
1554
+ */
1555
+ declare class SmoothSendTransactionSubmitter implements TransactionSubmitter {
1556
+ private readonly apiKey;
1557
+ private readonly network;
1558
+ private readonly gatewayUrl;
1559
+ private readonly timeout;
1560
+ private readonly debug;
1561
+ constructor(config: SmoothSendTransactionSubmitterConfig);
1562
+ /**
1563
+ * Submit a transaction through SmoothSend's gasless relayer
1564
+ *
1565
+ * This method is called automatically by the Aptos Wallet Adapter when
1566
+ * you use signAndSubmitTransaction. The transaction is submitted to
1567
+ * SmoothSend's relayer which sponsors the gas fees.
1568
+ */
1569
+ submitTransaction(args: {
1570
+ aptosConfig: AptosConfig;
1571
+ transaction: AnyRawTransaction;
1572
+ senderAuthenticator: AccountAuthenticator;
1573
+ feePayerAuthenticator?: AccountAuthenticator;
1574
+ additionalSignersAuthenticators?: Array<AccountAuthenticator>;
1575
+ pluginParams?: Record<string, unknown>;
1576
+ }): Promise<PendingTransactionResponse>;
1577
+ /**
1578
+ * Make an HTTP request to the SmoothSend gateway
1579
+ */
1580
+ private makeRequest;
1581
+ /**
1582
+ * Get the current configuration
1583
+ */
1584
+ getConfig(): Readonly<SmoothSendTransactionSubmitterConfig>;
1585
+ }
1586
+ /**
1587
+ * Create a SmoothSend transaction submitter with minimal configuration
1588
+ *
1589
+ * @example
1590
+ * ```typescript
1591
+ * const submitter = createSmoothSendSubmitter('pk_nogas_your_key');
1592
+ * ```
1593
+ */
1594
+ declare function createSmoothSendSubmitter(apiKey: string, options?: Partial<Omit<SmoothSendTransactionSubmitterConfig, 'apiKey'>>): SmoothSendTransactionSubmitter;
1595
+
1596
+ /**
1597
+ * Script Composer Client
1598
+ *
1599
+ * Wrapper for Script Composer gasless transactions.
1600
+ * Use this for token transfers on mainnet with free tier (fee deducted from token).
1601
+ *
1602
+ * @remarks
1603
+ * Script Composer builds a batched transaction that:
1604
+ * 1. Withdraws (amount + fee) from sender
1605
+ * 2. Deposits amount to recipient
1606
+ * 3. Deposits fee to treasury
1607
+ *
1608
+ * This allows gasless transactions where the fee is paid in the token being transferred.
1609
+ *
1610
+ * @example
1611
+ * ```typescript
1612
+ * import { ScriptComposerClient } from '@smoothsend/aptos-sdk';
1613
+ *
1614
+ * const client = new ScriptComposerClient({
1615
+ * apiKey: 'pk_nogas_xxx',
1616
+ * network: 'mainnet'
1617
+ * });
1618
+ *
1619
+ * // Step 1: Build transaction (fee calculated automatically)
1620
+ * const { transactionBytes, fee, totalAmount } = await client.buildTransfer({
1621
+ * sender: wallet.address,
1622
+ * recipient: '0x123...',
1623
+ * amount: '1000000', // 1 USDC (6 decimals)
1624
+ * assetType: '0x...::usdc::USDC',
1625
+ * decimals: 6,
1626
+ * symbol: 'USDC'
1627
+ * });
1628
+ *
1629
+ * // Step 2: Sign with wallet
1630
+ * const signedTx = await wallet.signTransaction(transactionBytes);
1631
+ *
1632
+ * // Step 3: Submit
1633
+ * const result = await client.submitSignedTransaction({
1634
+ * transactionBytes: signedTx.transactionBytes,
1635
+ * authenticatorBytes: signedTx.authenticatorBytes
1636
+ * });
1637
+ *
1638
+ * console.log('Tx:', result.txHash);
1639
+ * ```
1640
+ */
1641
+ /**
1642
+ * Configuration for Script Composer Client
1643
+ */
1644
+ interface ScriptComposerConfig {
1645
+ /** API key for authentication (pk_nogas_* or sk_nogas_*) */
1646
+ apiKey: string;
1647
+ /** Network to use: 'testnet' or 'mainnet' */
1648
+ network: 'testnet' | 'mainnet';
1649
+ /** Custom proxy URL (optional, defaults to proxy.smoothsend.xyz) */
1650
+ proxyUrl?: string;
1651
+ /** Request timeout in milliseconds (default: 30000) */
1652
+ timeout?: number;
1653
+ /** Enable debug logging */
1654
+ debug?: boolean;
1655
+ }
1656
+ /**
1657
+ * Parameters for building a Script Composer transfer
1658
+ */
1659
+ interface BuildTransferParams {
1660
+ /** Sender's wallet address */
1661
+ sender: string;
1662
+ /** Recipient's wallet address */
1663
+ recipient: string;
1664
+ /** Amount in smallest units (e.g., 1000000 for 1 USDC) */
1665
+ amount: string;
1666
+ /** Full asset type address (e.g., '0x...::usdc::USDC') */
1667
+ assetType: string;
1668
+ /** Token decimals (e.g., 6 for USDC, 8 for APT) */
1669
+ decimals: number;
1670
+ /** Token symbol (e.g., 'USDC', 'APT') */
1671
+ symbol: string;
1672
+ }
1673
+ /**
1674
+ * Result from building a transfer
1675
+ */
1676
+ interface BuildTransferResult {
1677
+ /** Success status */
1678
+ success: boolean;
1679
+ /** Request ID for tracking */
1680
+ requestId: string;
1681
+ /** Serialized transaction bytes for wallet signing */
1682
+ transactionBytes: number[];
1683
+ /** Transaction details */
1684
+ transaction: {
1685
+ sender: string;
1686
+ recipient: string;
1687
+ amount: string;
1688
+ assetType: string;
1689
+ network: string;
1690
+ };
1691
+ /** Fee amount in smallest units */
1692
+ fee: string;
1693
+ /** Total amount (amount + fee) in smallest units */
1694
+ totalAmount: string;
1695
+ /** Fee breakdown with formatted values */
1696
+ feeBreakdown: {
1697
+ amount: string;
1698
+ fee: string;
1699
+ totalAmount: string;
1700
+ formatted: {
1701
+ amount: string;
1702
+ fee: string;
1703
+ totalAmount: string;
1704
+ };
1705
+ pricing: {
1706
+ tier: string;
1707
+ zeroFees: boolean;
1708
+ feeInUsd: number;
1709
+ tokenPrice: number | null;
1710
+ description: string;
1711
+ };
1712
+ };
1713
+ }
1714
+ /**
1715
+ * Parameters for submitting a signed transaction
1716
+ */
1717
+ interface SubmitSignedTransactionParams {
1718
+ /** Serialized transaction bytes (from wallet signing) */
1719
+ transactionBytes: number[];
1720
+ /** Serialized authenticator bytes (from wallet signing) */
1721
+ authenticatorBytes: number[];
1722
+ }
1723
+ /**
1724
+ * Result from submitting a transaction
1725
+ */
1726
+ interface SubmitTransactionResult {
1727
+ /** Success status */
1728
+ success: boolean;
1729
+ /** Request ID for tracking */
1730
+ requestId: string;
1731
+ /** Transaction hash */
1732
+ txHash: string;
1733
+ /** Gas used */
1734
+ gasUsed?: string;
1735
+ /** VM status */
1736
+ vmStatus?: string;
1737
+ /** Sender address */
1738
+ sender?: string;
1739
+ }
1740
+ /**
1741
+ * Fee estimation result
1742
+ */
1743
+ interface FeeEstimateResult {
1744
+ /** Success status */
1745
+ success: boolean;
1746
+ /** Request ID for tracking */
1747
+ requestId: string;
1748
+ /** Fee estimation details */
1749
+ estimation: {
1750
+ /** Amount in smallest units */
1751
+ amount: string;
1752
+ /** Fee in smallest units */
1753
+ fee: string;
1754
+ /** Total amount in smallest units */
1755
+ totalAmount: string;
1756
+ /** Formatted values for display */
1757
+ formatted: {
1758
+ amount: string;
1759
+ fee: string;
1760
+ totalAmount: string;
1761
+ };
1762
+ /** Pricing information */
1763
+ pricing: {
1764
+ tier: string;
1765
+ zeroFees: boolean;
1766
+ feeInUsd: number;
1767
+ tokenPrice: number | null;
1768
+ description: string;
1769
+ };
1770
+ /** Usage information */
1771
+ usage: {
1772
+ monthlyLimit: number;
1773
+ usedThisMonth: number;
1774
+ remaining: number;
1775
+ };
1776
+ };
1777
+ }
1778
+ /**
1779
+ * Script Composer Client
1780
+ *
1781
+ * For gasless token transfers with fee deducted from the token.
1782
+ * Use this on mainnet with free tier, or anytime you want fee-in-token.
1783
+ */
1784
+ declare class ScriptComposerClient {
1785
+ private httpClient;
1786
+ private config;
1787
+ constructor(config: ScriptComposerConfig);
1788
+ private isBrowser;
1789
+ private log;
1790
+ /**
1791
+ * Estimate fee for a transfer without building the transaction
1792
+ *
1793
+ * @param params Transfer parameters
1794
+ * @returns Fee estimation with pricing details
1795
+ */
1796
+ estimateFee(params: BuildTransferParams): Promise<FeeEstimateResult>;
1797
+ /**
1798
+ * Build a gasless transfer transaction
1799
+ *
1800
+ * Returns unsigned transaction bytes that must be signed by the user's wallet.
1801
+ * The fee will be deducted from the token being transferred.
1802
+ *
1803
+ * @param params Transfer parameters
1804
+ * @returns Transaction bytes for signing and fee details
1805
+ */
1806
+ buildTransfer(params: BuildTransferParams): Promise<BuildTransferResult>;
1807
+ /**
1808
+ * Submit a signed transaction
1809
+ *
1810
+ * After the user signs the transaction bytes returned by buildTransfer(),
1811
+ * use this method to submit the signed transaction.
1812
+ *
1813
+ * @param params Signed transaction bytes
1814
+ * @returns Transaction result with hash
1815
+ */
1816
+ submitSignedTransaction(params: SubmitSignedTransactionParams): Promise<SubmitTransactionResult>;
1817
+ /**
1818
+ * Complete transfer flow: build, sign, and submit
1819
+ *
1820
+ * Convenience method that handles the entire flow.
1821
+ * Requires a wallet that can sign transactions.
1822
+ *
1823
+ * @param params Transfer parameters
1824
+ * @param wallet Wallet with signTransaction method
1825
+ * @returns Transaction result
1826
+ *
1827
+ * @example
1828
+ * ```typescript
1829
+ * const result = await client.transfer({
1830
+ * sender: wallet.address,
1831
+ * recipient: '0x123...',
1832
+ * amount: '1000000',
1833
+ * assetType: USDC_ADDRESS,
1834
+ * decimals: 6,
1835
+ * symbol: 'USDC'
1836
+ * }, wallet);
1837
+ * ```
1838
+ */
1839
+ transfer(params: BuildTransferParams, wallet: {
1840
+ signTransaction: (txBytes: number[]) => Promise<{
1841
+ transactionBytes: number[];
1842
+ authenticatorBytes: number[];
1843
+ }>;
1844
+ }): Promise<SubmitTransactionResult>;
1845
+ /**
1846
+ * Get current network
1847
+ */
1848
+ getNetwork(): 'testnet' | 'mainnet';
1849
+ /**
1850
+ * Set network
1851
+ */
1852
+ setNetwork(network: 'testnet' | 'mainnet'): void;
1853
+ }
1854
+ /**
1855
+ * Create a Script Composer client (convenience function)
1856
+ */
1857
+ declare function createScriptComposerClient(config: ScriptComposerConfig): ScriptComposerClient;
1858
+
1859
+ /**
1860
+ * Aptos Multi-Chain Adapter - v2 Proxy Architecture
1861
+ * Handles all Aptos chains (aptos-testnet, aptos-mainnet)
1862
+ * Routes all requests through proxy.smoothsend.xyz with API key authentication
1863
+ * Supports Aptos-specific features like gasless transactions and Move-based contracts
1864
+ */
1865
+ declare class AptosAdapter implements IChainAdapter {
1866
+ readonly chain: SupportedChain;
1867
+ readonly config: ChainConfig;
1868
+ private httpClient;
1869
+ private apiKey;
1870
+ private network;
1871
+ constructor(chain: SupportedChain, config: ChainConfig, apiKey: string, network?: 'testnet' | 'mainnet', includeOrigin?: boolean);
1872
+ /**
1873
+ * Build API path for proxy worker routing to Aptos relayer
1874
+ * All requests route through /api/v1/relayer/aptos/* endpoints
1875
+ */
1876
+ private getApiPath;
1877
+ /**
1878
+ * Update network parameter for subsequent requests
1879
+ * Network is passed via X-Network header to proxy worker
1880
+ */
1881
+ setNetwork(network: 'testnet' | 'mainnet'): void;
1882
+ /**
1883
+ * Get current network
1884
+ */
1885
+ getNetwork(): 'testnet' | 'mainnet';
1886
+ /**
1887
+ * Estimate fee for a transfer (v2 interface method)
1888
+ * Routes through proxy: POST /api/v1/relayer/aptos/quote
1889
+ */
1890
+ estimateFee(request: TransferRequest): Promise<FeeEstimate>;
1891
+ /**
1892
+ * Execute gasless transfer (v2 interface method)
1893
+ * Routes through proxy: POST /api/v1/relayer/aptos/execute
1894
+ */
1895
+ executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
1896
+ /**
1897
+ * Get quote for a transfer (legacy method, kept for backward compatibility)
1898
+ * Routes through proxy: POST /api/v1/relayer/aptos/quote
1899
+ */
1900
+ getQuote(request: TransferRequest): Promise<TransferQuote>;
1901
+ prepareTransfer(request: TransferRequest, quote: TransferQuote): Promise<SignatureData>;
1902
+ executeTransfer(signedData: SignedTransferData): Promise<TransferResult>;
1903
+ getBalance(address: string, token?: string): Promise<TokenBalance[]>;
1904
+ getTokenInfo(token: string): Promise<TokenInfo>;
1905
+ getNonce(address: string): Promise<string>;
1906
+ getTransactionStatus(txHash: string): Promise<any>;
1907
+ /**
1908
+ * Get health status of Aptos relayer through proxy
1909
+ * Routes through proxy: GET /api/v1/relayer/aptos/health
1910
+ */
1911
+ getHealth(): Promise<HealthResponse>;
1912
+ validateAddress(address: string): boolean;
1913
+ validateAmount(amount: string): boolean;
1914
+ /**
1915
+ * Get Aptos token address from symbol
1916
+ */
1917
+ private getAptosTokenAddress;
1918
+ /**
1919
+ * Build Aptos explorer URL for transaction
1920
+ */
1921
+ private buildAptosExplorerUrl;
1922
+ /**
1923
+ * Validate serialized transaction data for proxy worker
1924
+ * @param signedData The signed transfer data to validate
1925
+ */
1926
+ private validateSerializedTransactionData;
1927
+ /**
1928
+ * Enhanced address validation with detailed error messages
1929
+ * @param address The address to validate
1930
+ * @returns true if valid, throws error if invalid
1931
+ */
1932
+ validateAddressStrict(address: string): boolean;
1933
+ /**
1934
+ * Verify that a public key corresponds to an expected address
1935
+ * This mirrors the enhanced verification in the relayer
1936
+ * @param publicKey The public key to verify
1937
+ * @param expectedAddress The expected address
1938
+ * @returns true if they match
1939
+ */
1940
+ verifyPublicKeyAddress(publicKey: string, expectedAddress: string): Promise<boolean>;
1941
+ /**
1942
+ * Enhanced transaction preparation with better signature data structure
1943
+ * @param request Transfer request
1944
+ * @param quote Transfer quote
1945
+ * @returns Signature data with enhanced structure
1946
+ */
1947
+ prepareTransferEnhanced(request: TransferRequest, quote: TransferQuote): Promise<SignatureData & {
1948
+ metadata: any;
1949
+ }>;
1950
+ /**
1951
+ * Aptos-specific Move contract interaction
1952
+ */
1953
+ callMoveFunction(functionName: string, args: any[]): Promise<any>;
1954
+ }
1955
+
1956
+ /**
1957
+ * Configuration for HTTP client
1958
+ */
1959
+ interface HttpClientConfig {
1960
+ apiKey: string;
1961
+ network?: 'testnet' | 'mainnet';
1962
+ timeout?: number;
1963
+ retries?: number;
1964
+ customHeaders?: Record<string, string>;
1965
+ includeOrigin?: boolean;
1966
+ }
1967
+ /**
1968
+ * HTTP Client for proxy worker integration
1969
+ * Handles authentication, rate limiting, usage tracking, and retry logic
1970
+ */
1971
+ declare class HttpClient {
1972
+ private client;
1973
+ private apiKey?;
1974
+ private network;
1975
+ private maxRetries;
1976
+ private baseURL;
1977
+ private isProxyMode;
1978
+ private includeOrigin;
1979
+ /**
1980
+ * Constructor supports both old (baseURL, timeout) and new (config object) patterns
1981
+ * for backward compatibility during migration
1982
+ */
1983
+ constructor(configOrBaseURL: HttpClientConfig | string, timeout?: number);
1984
+ /**
1985
+ * Extract usage metadata from response headers (proxy mode only)
1986
+ * Uses USAGE_HEADERS constants for consistency across systems
1987
+ */
1988
+ private extractMetadata;
1989
+ /**
1990
+ * Determine if an error should be retried
1991
+ */
1992
+ private shouldRetry;
1993
+ /**
1994
+ * Calculate exponential backoff delay with jitter
1995
+ */
1996
+ private calculateBackoff;
1997
+ /**
1998
+ * Execute request with retry logic (proxy mode) or single attempt (legacy mode)
1999
+ */
2000
+ private executeWithRetry;
2001
+ /**
2002
+ * Handle errors and create appropriate error responses
2003
+ */
2004
+ private handleError;
2005
+ /**
2006
+ * GET request
2007
+ */
2008
+ get<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
2009
+ /**
2010
+ * POST request
2011
+ */
2012
+ post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
2013
+ /**
2014
+ * PUT request
2015
+ */
2016
+ put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
2017
+ /**
2018
+ * DELETE request
2019
+ */
2020
+ delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
2021
+ /**
2022
+ * Update network parameter for subsequent requests
2023
+ */
2024
+ setNetwork(network: 'testnet' | 'mainnet'): void;
2025
+ /**
2026
+ * Get current network
2027
+ */
2028
+ getNetwork(): 'testnet' | 'mainnet';
2029
+ }
2030
+
2031
+ /**
2032
+ * SmoothSend SDK v2.0
2033
+ *
2034
+ * Multi-chain gasless transaction SDK for seamless dApp integration
2035
+ *
2036
+ * @remarks
2037
+ * The SDK provides a simple interface for executing gasless token transfers
2038
+ * across multiple blockchain networks. All requests route through the proxy
2039
+ * worker at proxy.smoothsend.xyz with API key authentication.
2040
+ *
2041
+ * @packageDocumentation
2042
+ *
2043
+ * @example
2044
+ * Basic usage:
2045
+ * ```typescript
2046
+ * import { SmoothSendSDK } from '@smoothsend/sdk';
2047
+ *
2048
+ * const sdk = new SmoothSendSDK({
2049
+ * apiKey: 'no_gas_abc123...',
2050
+ * network: 'testnet'
2051
+ * });
2052
+ *
2053
+ * const result = await sdk.transfer({
2054
+ * from: '0x123...',
2055
+ * to: '0x456...',
2056
+ * token: 'USDC',
2057
+ * amount: '1000000',
2058
+ * chain: 'aptos-testnet'
2059
+ * }, wallet);
2060
+ *
2061
+ * console.log('Transaction:', result.txHash);
2062
+ * ```
2063
+ */
2064
+
2065
+ /**
2066
+ * SDK version
2067
+ * @public
2068
+ */
2069
+ declare const VERSION = "2.1.0";
2070
+
2071
+ export { APTOS_ERROR_CODES, AptosAdapter, AuthenticationError, CHAIN_ECOSYSTEM_MAP, HttpClient, NetworkError, RateLimitError, ScriptComposerClient, SmoothSendError, SmoothSendSDK, SmoothSendTransactionSubmitter, VERSION, ValidationError, createErrorFromResponse, createNetworkError, createScriptComposerClient, createSmoothSendSubmitter, SmoothSendSDK as default };
2072
+ export type { ApiResponse, AptosErrorCode, AptosTransferData, AvalancheTransferData, BatchRelayTransferRequest, BatchTransferRequest, BuildTransferParams, BuildTransferResult, ChainConfig, ChainEcosystem, ChainInfo, DomainSeparatorResponse, EVMTransferData, ErrorResponse, EstimateGasRequest, EventListener, FeeEstimate, FeeEstimateResult, GasEstimateResponse, HealthResponse, IChainAdapter, PermitData, PrepareSignatureRequest, PrepareSignatureResponse, RelayTransferRequest, RelayTransferResponse, ScriptComposerConfig, SignatureData, SignedTransferData, SmoothSendConfig, SmoothSendTransactionSubmitterConfig, SubmitSignedTransactionParams, SubmitTransactionResult, SuccessResponse, SupportedChain, TokenBalance, TokenInfo, TransactionSubmitter, TransferData, TransferEvent, TransferQuote, TransferQuoteRequest, TransferQuoteResponse, TransferRequest, TransferResult, TransferStatusResponse, UsageMetadata };