@smoothsend/sdk 2.2.1 → 2.2.3

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 (81) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +349 -349
  3. package/dist/aptos/index.cjs +1256 -0
  4. package/dist/aptos/index.cjs.map +1 -0
  5. package/dist/aptos/index.d.ts +783 -0
  6. package/dist/aptos/index.js +1230 -0
  7. package/dist/aptos/index.js.map +1 -0
  8. package/dist/aptos-entry.d.ts +36 -0
  9. package/dist/aptos-entry.d.ts.map +1 -0
  10. package/dist/avax/SmoothSendAvaxSubmitter.d.ts +79 -0
  11. package/dist/avax/SmoothSendAvaxSubmitter.d.ts.map +1 -0
  12. package/dist/avax/index.cjs +1869 -0
  13. package/dist/avax/index.cjs.map +1 -0
  14. package/dist/avax/index.d.ts +306 -0
  15. package/dist/avax/index.d.ts.map +1 -0
  16. package/dist/avax/index.js +1849 -0
  17. package/dist/avax/index.js.map +1 -0
  18. package/dist/avax/publicAaDefaults.d.ts +16 -0
  19. package/dist/avax/publicAaDefaults.d.ts.map +1 -0
  20. package/dist/avax/simpleAccountFactory.d.ts +44 -0
  21. package/dist/avax/simpleAccountFactory.d.ts.map +1 -0
  22. package/dist/avax/types.d.ts +86 -0
  23. package/dist/avax/types.d.ts.map +1 -0
  24. package/dist/avax/useSmoothSendAvax.d.ts +60 -0
  25. package/dist/avax/useSmoothSendAvax.d.ts.map +1 -0
  26. package/dist/avax/viemHelpers.d.ts +40 -0
  27. package/dist/avax/viemHelpers.d.ts.map +1 -0
  28. package/dist/avax-entry.d.ts +24 -0
  29. package/dist/avax-entry.d.ts.map +1 -0
  30. package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs +1519 -0
  31. package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs.map +1 -0
  32. package/dist/chunks/SmoothSendSDK-CaV_PCIG.js +1511 -0
  33. package/dist/chunks/SmoothSendSDK-CaV_PCIG.js.map +1 -0
  34. package/dist/chunks/SmoothSendSDK.d-9GBgZONY.d.ts +262 -0
  35. package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs +1237 -0
  36. package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs.map +1 -0
  37. package/dist/chunks/TrueGaslessClient-l2uFvNAa.js +1228 -0
  38. package/dist/chunks/TrueGaslessClient-l2uFvNAa.js.map +1 -0
  39. package/dist/chunks/shared-CNF22ESH.js +557 -0
  40. package/dist/chunks/shared-CNF22ESH.js.map +1 -0
  41. package/dist/chunks/shared-CaQMAGQR.js +1511 -0
  42. package/dist/chunks/shared-CaQMAGQR.js.map +1 -0
  43. package/dist/chunks/shared-Cn4duBJT.d.ts +1279 -0
  44. package/dist/chunks/shared-DEurKmpI.cjs +1519 -0
  45. package/dist/chunks/shared-DEurKmpI.cjs.map +1 -0
  46. package/dist/chunks/shared-RVkwmkG7.d.ts +262 -0
  47. package/dist/chunks/shared-x1-VC-Li.cjs +568 -0
  48. package/dist/chunks/shared-x1-VC-Li.cjs.map +1 -0
  49. package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs +1865 -0
  50. package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs.map +1 -0
  51. package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js +1848 -0
  52. package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js.map +1 -0
  53. package/dist/chunks/version-CNF22ESH.js +557 -0
  54. package/dist/chunks/version-CNF22ESH.js.map +1 -0
  55. package/dist/chunks/version-x1-VC-Li.cjs +568 -0
  56. package/dist/chunks/version-x1-VC-Li.cjs.map +1 -0
  57. package/dist/chunks/version.d-Cn4duBJT.d.ts +1279 -0
  58. package/dist/index.cjs +5209 -0
  59. package/dist/index.cjs.map +1 -0
  60. package/dist/index.d.ts +11 -2552
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.esm.js +1846 -3
  63. package/dist/index.esm.js.map +1 -1
  64. package/dist/index.js +1880 -62
  65. package/dist/index.js.map +1 -1
  66. package/dist/stellar/index.cjs +27 -0
  67. package/dist/stellar/index.cjs.map +1 -0
  68. package/dist/stellar/index.d.ts +214 -0
  69. package/dist/stellar/index.js +3 -0
  70. package/dist/stellar/index.js.map +1 -0
  71. package/dist/stellar-entry.d.ts +37 -0
  72. package/dist/stellar-entry.d.ts.map +1 -0
  73. package/dist/version.d.ts +2 -0
  74. package/dist/version.d.ts.map +1 -0
  75. package/package.json +120 -110
  76. package/dist/adapters/evm.d.ts +0 -39
  77. package/dist/adapters/evm.d.ts.map +0 -1
  78. package/dist/config/chains.d.ts +0 -7
  79. package/dist/config/chains.d.ts.map +0 -1
  80. package/dist/services/chainConfigService.d.ts +0 -49
  81. package/dist/services/chainConfigService.d.ts.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,2552 +1,11 @@
1
- import { AptosConfig, AnyRawTransaction, AccountAuthenticator, PendingTransactionResponse, Account, InputGenerateTransactionPayloadData, Aptos } from '@aptos-labs/ts-sdk';
2
- import { AxiosRequestConfig } from 'axios';
3
-
4
- /**
5
- * Error handling system for SmoothSend SDK v2
6
- * Provides typed error classes for different failure scenarios
7
- *
8
- * @remarks
9
- * All SDK errors extend SmoothSendError for consistent error handling
10
- * Use instanceof checks to handle specific error types
11
- *
12
- * @example
13
- * ```typescript
14
- * try {
15
- * await sdk.transfer(request, wallet);
16
- * } catch (error) {
17
- * if (error instanceof AuthenticationError) {
18
- * console.error('Invalid API key');
19
- * } else if (error instanceof RateLimitError) {
20
- * console.error('Rate limit exceeded');
21
- * }
22
- * }
23
- * ```
24
- */
25
- /**
26
- * Base error class for all SmoothSend SDK errors
27
- *
28
- * @remarks
29
- * All SDK-specific errors extend this class
30
- * Contains error code, HTTP status code, and additional details
31
- *
32
- * @example
33
- * ```typescript
34
- * throw new SmoothSendError(
35
- * 'Something went wrong',
36
- * 'CUSTOM_ERROR',
37
- * 500,
38
- * { additionalInfo: 'details' }
39
- * );
40
- * ```
41
- */
42
- declare class SmoothSendError extends Error {
43
- code: string;
44
- statusCode?: number | undefined;
45
- details?: any | undefined;
46
- /**
47
- * Creates a new SmoothSendError
48
- *
49
- * @param message - Human-readable error message
50
- * @param code - Error code for programmatic handling
51
- * @param statusCode - HTTP status code (if applicable)
52
- * @param details - Additional error details
53
- */
54
- constructor(message: string, code: string, statusCode?: number | undefined, details?: any | undefined);
55
- }
56
- /**
57
- * Authentication error - thrown when API key is invalid, missing, or expired
58
- *
59
- * @remarks
60
- * HTTP Status Code: 401
61
- * Indicates authentication failure with the proxy worker
62
- *
63
- * @example
64
- * ```typescript
65
- * try {
66
- * await sdk.transfer(request, wallet);
67
- * } catch (error) {
68
- * if (error instanceof AuthenticationError) {
69
- * console.error('Invalid API key:', error.message);
70
- * console.log('Get a new key at:', error.details.suggestion);
71
- * }
72
- * }
73
- * ```
74
- */
75
- declare class AuthenticationError extends SmoothSendError {
76
- /**
77
- * Creates a new AuthenticationError
78
- *
79
- * @param message - Human-readable error message
80
- * @param details - Additional error details
81
- */
82
- constructor(message: string, details?: any);
83
- }
84
- /**
85
- * Rate limit error - thrown when request rate limit is exceeded
86
- *
87
- * @remarks
88
- * HTTP Status Code: 429
89
- * Contains rate limit details including reset time
90
- *
91
- * @example
92
- * ```typescript
93
- * try {
94
- * await sdk.transfer(request, wallet);
95
- * } catch (error) {
96
- * if (error instanceof RateLimitError) {
97
- * console.error('Rate limit exceeded');
98
- * console.log(`Limit: ${error.limit}`);
99
- * console.log(`Remaining: ${error.remaining}`);
100
- * console.log(`Resets at: ${error.resetTime}`);
101
- * }
102
- * }
103
- * ```
104
- */
105
- declare class RateLimitError extends SmoothSendError {
106
- limit: number;
107
- remaining: number;
108
- resetTime: string;
109
- /**
110
- * Creates a new RateLimitError
111
- *
112
- * @param message - Human-readable error message
113
- * @param limit - Maximum requests allowed per period
114
- * @param remaining - Remaining requests in current period
115
- * @param resetTime - When the rate limit resets (ISO 8601 timestamp)
116
- */
117
- constructor(message: string, limit: number, remaining: number, resetTime: string);
118
- }
119
- /**
120
- * Validation error - thrown when request parameters are invalid
121
- *
122
- * @remarks
123
- * HTTP Status Code: 400
124
- * Contains field name that failed validation
125
- *
126
- * @example
127
- * ```typescript
128
- * try {
129
- * await sdk.transfer(request, wallet);
130
- * } catch (error) {
131
- * if (error instanceof ValidationError) {
132
- * console.error(`Invalid ${error.field}:`, error.message);
133
- * }
134
- * }
135
- * ```
136
- */
137
- declare class ValidationError extends SmoothSendError {
138
- field: string;
139
- /**
140
- * Creates a new ValidationError
141
- *
142
- * @param message - Human-readable error message
143
- * @param field - Name of the field that failed validation
144
- * @param details - Additional error details
145
- */
146
- constructor(message: string, field: string, details?: any);
147
- }
148
- /**
149
- * Network error - thrown when network connectivity issues occur
150
- *
151
- * @remarks
152
- * HTTP Status Code: 0 (no HTTP response)
153
- * Indicates network connectivity problems
154
- *
155
- * @example
156
- * ```typescript
157
- * try {
158
- * await sdk.transfer(request, wallet);
159
- * } catch (error) {
160
- * if (error instanceof NetworkError) {
161
- * console.error('Network error:', error.message);
162
- * console.log('Original error:', error.originalError);
163
- * }
164
- * }
165
- * ```
166
- */
167
- declare class NetworkError extends SmoothSendError {
168
- originalError?: Error | undefined;
169
- /**
170
- * Creates a new NetworkError
171
- *
172
- * @param message - Human-readable error message
173
- * @param originalError - Original error that caused the network failure
174
- */
175
- constructor(message: string, originalError?: Error | undefined);
176
- }
177
- /**
178
- * Helper function to create appropriate error from HTTP response
179
- *
180
- * @remarks
181
- * Parses HTTP error response and creates typed error object
182
- * Used internally by HTTP client
183
- *
184
- * @param statusCode - HTTP status code
185
- * @param errorData - Error response data from API
186
- * @param defaultMessage - Default message if none provided in response
187
- * @returns Typed error object
188
- *
189
- * @example
190
- * ```typescript
191
- * const error = createErrorFromResponse(401, {
192
- * error: 'Invalid API key',
193
- * details: { field: 'apiKey' }
194
- * });
195
- * throw error;
196
- * ```
197
- */
198
- declare function createErrorFromResponse(statusCode: number, errorData: any, defaultMessage?: string): SmoothSendError;
199
- /**
200
- * Helper function to create network error from exception
201
- *
202
- * @remarks
203
- * Wraps generic exceptions in NetworkError for consistent error handling
204
- * Used internally by HTTP client
205
- *
206
- * @param error - Original error or exception
207
- * @returns NetworkError instance
208
- *
209
- * @example
210
- * ```typescript
211
- * try {
212
- * await fetch(url);
213
- * } catch (error) {
214
- * throw createNetworkError(error);
215
- * }
216
- * ```
217
- */
218
- declare function createNetworkError(error: any): NetworkError;
219
-
220
- /**
221
- * Supported blockchain chains in the SmoothSend SDK
222
- *
223
- * @remarks
224
- * - `avalanche`: Avalanche C-Chain (EVM-compatible)
225
- * - `aptos-testnet`: Aptos testnet
226
- * - `aptos-mainnet`: Aptos mainnet
227
- */
228
- type SupportedChain = 'avalanche' | 'aptos-testnet' | 'aptos-mainnet' | 'stellar-testnet' | 'stellar-mainnet';
229
- /**
230
- * Chain ecosystem types for routing to correct relayers
231
- *
232
- * @remarks
233
- * - `evm`: Ethereum Virtual Machine compatible chains (Avalanche, Base, Arbitrum, etc.)
234
- * - `aptos`: Aptos blockchain ecosystem
235
- * - `stellar`: Stellar blockchain ecosystem
236
- */
237
- type ChainEcosystem = 'evm' | 'aptos' | 'stellar';
238
- /**
239
- * Mapping of supported chains to their respective ecosystems
240
- * Used internally for adapter selection and routing
241
- */
242
- declare const CHAIN_ECOSYSTEM_MAP: Record<SupportedChain, ChainEcosystem>;
243
- /**
244
- * Base success response structure
245
- * All successful API responses extend this interface
246
- */
247
- interface SuccessResponse {
248
- /** Indicates the request was successful */
249
- success: true;
250
- }
251
- /**
252
- * Base error response structure
253
- * All error API responses extend this interface
254
- */
255
- interface ErrorResponse {
256
- /** Indicates the request failed */
257
- success: false;
258
- /** Human-readable error message */
259
- error: string;
260
- /** Additional error details or validation errors */
261
- details?: string[];
262
- /** Unique request identifier for debugging */
263
- requestId?: string;
264
- }
265
- /**
266
- * Chain information structure
267
- * Contains metadata about a supported blockchain
268
- */
269
- interface ChainInfo {
270
- /** Chain identifier (e.g., 'aptos-testnet') */
271
- name: string;
272
- /** Human-readable chain name */
273
- displayName: string;
274
- /** Numeric chain ID */
275
- chainId: number;
276
- /** Block explorer base URL */
277
- explorerUrl: string;
278
- /** List of supported token symbols */
279
- tokens: string[];
280
- }
281
- /**
282
- * Token information structure
283
- * Contains metadata about a supported token
284
- */
285
- interface TokenInfo {
286
- /** Token symbol (e.g., 'USDC') */
287
- symbol: string;
288
- /** Token contract address */
289
- address: string;
290
- /** Number of decimal places */
291
- decimals: number;
292
- /** Full token name */
293
- name: string;
294
- }
295
- /**
296
- * Chain configuration structure
297
- * Complete configuration for a blockchain network
298
- */
299
- interface ChainConfig {
300
- /** Chain identifier */
301
- name: string;
302
- /** Human-readable chain name */
303
- displayName: string;
304
- /** Numeric chain ID */
305
- chainId: number;
306
- /** RPC endpoint URL */
307
- rpcUrl: string;
308
- /** Relayer service URL */
309
- relayerUrl: string;
310
- /** Block explorer base URL */
311
- explorerUrl: string;
312
- /** List of supported token symbols */
313
- tokens: string[];
314
- /** Native currency information */
315
- nativeCurrency: {
316
- /** Currency name */
317
- name: string;
318
- /** Currency symbol */
319
- symbol: string;
320
- /** Number of decimal places */
321
- decimals: number;
322
- };
323
- }
324
- /**
325
- * Transfer request parameters
326
- * Used to initiate a gasless token transfer
327
- *
328
- * @example
329
- * ```typescript
330
- * const request: TransferRequest = {
331
- * from: '0x123...',
332
- * to: '0x456...',
333
- * token: 'USDC',
334
- * amount: '1000000', // 1 USDC (6 decimals)
335
- * chain: 'aptos-testnet'
336
- * };
337
- * ```
338
- */
339
- interface TransferRequest {
340
- /** Sender's wallet address */
341
- from: string;
342
- /** Recipient's wallet address */
343
- to: string;
344
- /** Token symbol or contract address */
345
- token: string;
346
- /** Amount in smallest unit (wei, octas, etc.) */
347
- amount: string;
348
- /** Target blockchain */
349
- chain: SupportedChain;
350
- }
351
- /**
352
- * Transfer quote response from API
353
- * Contains fee information for a transfer
354
- */
355
- interface TransferQuoteResponse extends SuccessResponse {
356
- /** Chain identifier */
357
- chainName: string;
358
- /** Token symbol */
359
- token: string;
360
- /** Transfer amount */
361
- amount: string;
362
- /** Relayer fee amount */
363
- relayerFee: string;
364
- /** Total amount (amount + fee) */
365
- total: string;
366
- /** Fee as percentage of amount */
367
- feePercentage: number;
368
- /** Token contract address */
369
- contractAddress: string;
370
- }
371
- /**
372
- * Fee estimate response from proxy worker
373
- * Contains detailed fee information for a transfer
374
- *
375
- * @remarks
376
- * Returned by `estimateFee()` method
377
- */
378
- interface FeeEstimate {
379
- /** Fee charged by relayer in token units */
380
- relayerFee: string;
381
- /** Fee in USD for reference */
382
- feeInUSD: string;
383
- /** Full coin type identifier (e.g., '0x1::aptos_coin::AptosCoin') */
384
- coinType: string;
385
- /** Estimated gas units */
386
- estimatedGas: string;
387
- /** Network (testnet or mainnet) */
388
- network: 'testnet' | 'mainnet';
389
- }
390
- /**
391
- * Transfer quote information
392
- * Contains fee breakdown and contract details
393
- */
394
- interface TransferQuote {
395
- /** Transfer amount */
396
- amount: string;
397
- /** Relayer fee amount */
398
- relayerFee: string;
399
- /** Total amount (amount + fee) */
400
- total: string;
401
- /** Fee as percentage of amount */
402
- feePercentage: number;
403
- /** Token contract address */
404
- contractAddress: string;
405
- /** Aptos-specific transaction data (optional for backward compatibility) */
406
- aptosTransactionData?: any;
407
- }
408
- /**
409
- * Relay transfer response from API
410
- * Contains transaction execution details
411
- */
412
- interface RelayTransferResponse extends SuccessResponse {
413
- /** Unique transfer identifier */
414
- transferId: string;
415
- /** Transaction hash */
416
- txHash: string;
417
- /** Block number where transaction was included */
418
- blockNumber: number;
419
- /** Gas units consumed */
420
- gasUsed: string;
421
- /** Block explorer URL for transaction */
422
- explorerUrl: string;
423
- /** Fee paid for the transfer */
424
- fee: string;
425
- /** Execution time in milliseconds */
426
- executionTime: number;
427
- }
428
- /**
429
- * Transfer result structure
430
- * Contains complete information about a transfer execution
431
- *
432
- * @remarks
433
- * Returned by `executeGaslessTransfer()` and `transfer()` methods
434
- *
435
- * @example
436
- * ```typescript
437
- * const result = await sdk.executeGaslessTransfer(signedData);
438
- * console.log(`Transaction: ${result.txHash}`);
439
- * console.log(`Explorer: ${result.explorerUrl}`);
440
- * console.log(`Rate limit remaining: ${result.metadata?.rateLimit.remaining}`);
441
- * ```
442
- */
443
- interface TransferResult {
444
- /** Indicates if transfer was successful */
445
- success: boolean;
446
- /** Transaction hash */
447
- txHash: string;
448
- /** Block number where transaction was included */
449
- blockNumber?: number;
450
- /** Gas units consumed */
451
- gasUsed?: string;
452
- /** Unique transfer identifier */
453
- transferId?: string;
454
- /** Block explorer URL for transaction */
455
- explorerUrl?: string;
456
- /** Fee paid for the transfer */
457
- fee?: string;
458
- /** Execution time in milliseconds */
459
- executionTime?: number;
460
- /** Address that paid the gas fee (Aptos-specific) */
461
- gasFeePaidBy?: string;
462
- /** Whether user paid in APT (Aptos-specific) */
463
- userPaidAPT?: boolean;
464
- /** Transparency information (Aptos-specific) */
465
- transparency?: string;
466
- /** VM execution status (Aptos-specific) */
467
- vmStatus?: string;
468
- /** Sender address (Aptos-specific) */
469
- sender?: string;
470
- /** Chain identifier (Aptos-specific) */
471
- chain?: string;
472
- /** Relayer fee amount (Aptos-specific) */
473
- relayerFee?: string;
474
- /** Additional message or status information */
475
- message?: string;
476
- /** Usage metadata from proxy worker (v2) */
477
- metadata?: UsageMetadata;
478
- }
479
- /**
480
- * Batch transfer request parameters
481
- * Used to execute multiple transfers in a single transaction
482
- *
483
- * @remarks
484
- * Batch transfers are more gas-efficient than individual transfers
485
- */
486
- interface BatchTransferRequest {
487
- /** Array of transfer requests to execute */
488
- transfers: TransferRequest[];
489
- /** Target blockchain */
490
- chain: SupportedChain;
491
- }
492
- /**
493
- * EVM transfer data structure
494
- * Contains signed transfer data for EVM-compatible chains
495
- *
496
- * @remarks
497
- * Used for Avalanche and other EVM chains
498
- */
499
- interface EVMTransferData {
500
- /** Chain identifier */
501
- chainName: string;
502
- /** Sender address */
503
- from: string;
504
- /** Recipient address */
505
- to: string;
506
- /** Token symbol */
507
- tokenSymbol: string;
508
- /** Transfer amount */
509
- amount: string;
510
- /** Relayer fee amount */
511
- relayerFee: string;
512
- /** Transaction nonce */
513
- nonce: string;
514
- /** Signature deadline timestamp */
515
- deadline: number;
516
- /** EIP-712 signature */
517
- signature: string;
518
- /** ERC-2612 permit data (optional) */
519
- permitData?: {
520
- /** Permit value */
521
- value: string;
522
- /** Permit deadline */
523
- deadline: number;
524
- /** Signature v component */
525
- v: number;
526
- /** Signature r component */
527
- r: string;
528
- /** Signature s component */
529
- s: string;
530
- };
531
- }
532
- /**
533
- * Legacy type alias for Avalanche transfers
534
- * @deprecated Use EVMTransferData instead
535
- */
536
- type AvalancheTransferData = EVMTransferData;
537
- /**
538
- * Aptos transfer data structure
539
- * Contains serialized transaction data for secure Aptos transfers
540
- *
541
- * @remarks
542
- * Uses serialized transaction approach for enhanced security
543
- * Transaction must be built and signed by wallet before submission
544
- *
545
- * @example
546
- * ```typescript
547
- * const aptosData: AptosTransferData = {
548
- * transactionBytes: Array.from(signedTx.transactionBytes),
549
- * authenticatorBytes: Array.from(signedTx.authenticatorBytes)
550
- * };
551
- * ```
552
- */
553
- interface AptosTransferData {
554
- /** Serialized SimpleTransaction as byte array */
555
- transactionBytes: number[];
556
- /** Serialized AccountAuthenticator as byte array */
557
- authenticatorBytes: number[];
558
- /** Optional function name for debugging/tracking */
559
- functionName?: string;
560
- /** Sender address (optional metadata) */
561
- fromAddress?: string;
562
- /** Recipient address (optional metadata) */
563
- toAddress?: string;
564
- /** Transfer amount (optional metadata) */
565
- amount?: string;
566
- /** Coin type identifier (optional metadata) */
567
- coinType?: string;
568
- }
569
- /**
570
- * EIP-712 signature data structure
571
- * Contains typed data for signature verification
572
- */
573
- interface SignatureData {
574
- /** EIP-712 domain separator */
575
- domain: any;
576
- /** Type definitions */
577
- types: any;
578
- /** Message to sign */
579
- message: any;
580
- /** Primary type name */
581
- primaryType: string;
582
- /** Enhanced metadata for signature verification */
583
- metadata?: {
584
- /** Target chain */
585
- chain?: SupportedChain;
586
- /** Sender address */
587
- fromAddress?: string;
588
- /** Recipient address */
589
- toAddress?: string;
590
- /** Transfer amount */
591
- amount?: string;
592
- /** Token symbol */
593
- token?: string;
594
- /** Relayer fee */
595
- relayerFee?: string;
596
- /** Signature version */
597
- signatureVersion?: string;
598
- /** Whether public key is required */
599
- requiresPublicKey?: boolean;
600
- /** Verification method */
601
- verificationMethod?: string;
602
- };
603
- }
604
- /**
605
- * Signed transfer data for SDK v2
606
- * Contains serialized transaction bytes for secure Aptos transfers
607
- *
608
- * @remarks
609
- * Used with `executeGaslessTransfer()` method
610
- * Transaction must be built and signed by wallet before creating this structure
611
- *
612
- * @example
613
- * ```typescript
614
- * const signedData: SignedTransferData = {
615
- * transactionBytes: Array.from(signedTx.transactionBytes),
616
- * authenticatorBytes: Array.from(signedTx.authenticatorBytes),
617
- * chain: 'aptos-testnet',
618
- * network: 'testnet'
619
- * };
620
- * const result = await sdk.executeGaslessTransfer(signedData);
621
- * ```
622
- */
623
- interface SignedTransferData {
624
- /** Serialized transaction (Aptos) */
625
- transactionBytes?: number[];
626
- /** Serialized authenticator (Aptos) */
627
- authenticatorBytes?: number[];
628
- /** Signed XDR transaction (Stellar) */
629
- signedTransaction?: string;
630
- /** Target blockchain */
631
- chain: SupportedChain;
632
- /** Optional network override (testnet or mainnet) */
633
- network?: 'testnet' | 'mainnet';
634
- }
635
- /**
636
- * Token balance information
637
- * Contains balance and metadata for a specific token
638
- */
639
- interface TokenBalance {
640
- /** Token symbol or address */
641
- token: string;
642
- /** Balance in smallest unit */
643
- balance: string;
644
- /** Number of decimal places */
645
- decimals: number;
646
- /** Token symbol */
647
- symbol: string;
648
- /** Full token name (optional) */
649
- name?: string;
650
- }
651
- /**
652
- * Transfer quote request parameters
653
- * Used to request fee estimate from API
654
- */
655
- interface TransferQuoteRequest {
656
- /** Chain identifier */
657
- chainName: string;
658
- /** Token symbol */
659
- token: string;
660
- /** Transfer amount */
661
- amount: string;
662
- }
663
- /**
664
- * Prepare signature request parameters
665
- * Used to get typed data for EIP-712 signature
666
- */
667
- interface PrepareSignatureRequest {
668
- /** Chain identifier */
669
- chainName: string;
670
- /** Sender address */
671
- from: string;
672
- /** Recipient address */
673
- to: string;
674
- /** Token symbol */
675
- tokenSymbol: string;
676
- /** Transfer amount */
677
- amount: string;
678
- /** Relayer fee amount */
679
- relayerFee: string;
680
- /** Transaction nonce */
681
- nonce: string;
682
- /** Signature deadline timestamp */
683
- deadline: number;
684
- }
685
- /**
686
- * Relay transfer request parameters
687
- * Used to submit signed transfer to relayer
688
- */
689
- interface RelayTransferRequest {
690
- /** Chain identifier */
691
- chainName: string;
692
- /** Sender address */
693
- from: string;
694
- /** Recipient address */
695
- to: string;
696
- /** Token symbol */
697
- tokenSymbol: string;
698
- /** Transfer amount */
699
- amount: string;
700
- /** Relayer fee amount */
701
- relayerFee: string;
702
- /** Transaction nonce */
703
- nonce: string;
704
- /** Signature deadline timestamp */
705
- deadline: number;
706
- /** EIP-712 signature */
707
- signature: string;
708
- /** ERC-2612 permit data (optional) */
709
- permitData?: PermitData;
710
- }
711
- /**
712
- * Batch relay transfer request parameters
713
- * Used to submit multiple signed transfers in one transaction
714
- */
715
- interface BatchRelayTransferRequest {
716
- /** Chain identifier */
717
- chainName: string;
718
- /** Array of transfer requests */
719
- transfers: RelayTransferRequest[];
720
- }
721
- /**
722
- * Gas estimate request parameters
723
- * Used to estimate gas cost for transfers
724
- */
725
- interface EstimateGasRequest {
726
- /** Chain identifier */
727
- chainName: string;
728
- /** Array of transfer data */
729
- transfers: TransferData[];
730
- }
731
- /**
732
- * Transfer data structure
733
- * Contains complete transfer information including signature
734
- */
735
- interface TransferData {
736
- /** Sender address */
737
- from: string;
738
- /** Recipient address */
739
- to: string;
740
- /** Token symbol or address */
741
- token: string;
742
- /** Transfer amount */
743
- amount: string;
744
- /** Relayer fee amount */
745
- relayerFee: string;
746
- /** Transaction nonce */
747
- nonce: string;
748
- /** Signature deadline timestamp */
749
- deadline: number;
750
- /** EIP-712 signature */
751
- signature: string;
752
- /** ERC-2612 permit data (optional) */
753
- permitData?: PermitData;
754
- }
755
- /**
756
- * ERC-2612 permit data structure
757
- * Used for gasless token approvals
758
- */
759
- interface PermitData {
760
- /** Permit value (amount) */
761
- value: string;
762
- /** Permit deadline timestamp */
763
- deadline: number;
764
- /** Signature v component */
765
- v: number;
766
- /** Signature r component */
767
- r: string;
768
- /** Signature s component */
769
- s: string;
770
- }
771
- /**
772
- * Prepare signature response from API
773
- * Contains EIP-712 typed data for signing
774
- */
775
- interface PrepareSignatureResponse extends SuccessResponse {
776
- /** EIP-712 typed data structure */
777
- typedData: any;
778
- /** Keccak256 hash of the message */
779
- messageHash: string;
780
- /** Human-readable message */
781
- message: string;
782
- }
783
- /**
784
- * Gas estimate response from API
785
- * Contains estimated gas cost for transfers
786
- */
787
- interface GasEstimateResponse extends SuccessResponse {
788
- /** Chain identifier */
789
- chainName: string;
790
- /** Estimated gas units */
791
- gasEstimate: string;
792
- /** Current gas price */
793
- gasPrice: string;
794
- /** Estimated cost in native currency */
795
- estimatedCost: string;
796
- /** Number of transfers in batch */
797
- transferCount: number;
798
- }
799
- /**
800
- * Health check response
801
- * Contains service health status information
802
- *
803
- * @remarks
804
- * Returned by `getHealth()` and `getChainHealth()` methods
805
- */
806
- interface HealthResponse extends SuccessResponse {
807
- /** Service status (e.g., 'healthy', 'degraded') */
808
- status: string;
809
- /** Response timestamp (ISO 8601) */
810
- timestamp: string;
811
- /** Service version */
812
- version: string;
813
- }
814
- /**
815
- * Domain separator response from API
816
- * Contains EIP-712 domain separator for a chain
817
- */
818
- interface DomainSeparatorResponse extends SuccessResponse {
819
- /** Chain identifier */
820
- chainName: string;
821
- /** EIP-712 domain separator hash */
822
- domainSeparator: string;
823
- }
824
- /**
825
- * Transfer status response from API
826
- * Contains execution status of a transfer
827
- */
828
- interface TransferStatusResponse extends SuccessResponse {
829
- /** Chain identifier */
830
- chainName: string;
831
- /** Transfer transaction hash */
832
- transferHash: string;
833
- /** Whether transfer has been executed */
834
- executed: boolean;
835
- }
836
- /**
837
- * Aptos-specific error codes
838
- * Used for detailed error handling in Aptos adapter
839
- *
840
- * @remarks
841
- * Error codes are prefixed with APTOS_ for easy identification
842
- */
843
- declare const APTOS_ERROR_CODES: {
844
- /** Missing signature in request */
845
- readonly MISSING_SIGNATURE: "APTOS_MISSING_SIGNATURE";
846
- /** Missing public key for verification */
847
- readonly MISSING_PUBLIC_KEY: "APTOS_MISSING_PUBLIC_KEY";
848
- /** Invalid signature format */
849
- readonly INVALID_SIGNATURE_FORMAT: "APTOS_INVALID_SIGNATURE_FORMAT";
850
- /** Invalid public key format */
851
- readonly INVALID_PUBLIC_KEY_FORMAT: "APTOS_INVALID_PUBLIC_KEY_FORMAT";
852
- /** Address doesn't match public key */
853
- readonly ADDRESS_MISMATCH: "APTOS_ADDRESS_MISMATCH";
854
- /** Signature verification failed */
855
- readonly SIGNATURE_VERIFICATION_FAILED: "APTOS_SIGNATURE_VERIFICATION_FAILED";
856
- /** Missing transaction data */
857
- readonly MISSING_TRANSACTION_DATA: "APTOS_MISSING_TRANSACTION_DATA";
858
- /** Invalid transaction format */
859
- readonly INVALID_TRANSACTION_FORMAT: "APTOS_INVALID_TRANSACTION_FORMAT";
860
- /** Empty address provided */
861
- readonly EMPTY_ADDRESS: "APTOS_EMPTY_ADDRESS";
862
- /** Invalid address format */
863
- readonly INVALID_ADDRESS_FORMAT: "APTOS_INVALID_ADDRESS_FORMAT";
864
- /** Error fetching quote */
865
- readonly QUOTE_ERROR: "APTOS_QUOTE_ERROR";
866
- /** Error executing transfer */
867
- readonly EXECUTE_ERROR: "APTOS_EXECUTE_ERROR";
868
- /** Error fetching balance */
869
- readonly BALANCE_ERROR: "APTOS_BALANCE_ERROR";
870
- /** Error fetching token info */
871
- readonly TOKEN_INFO_ERROR: "APTOS_TOKEN_INFO_ERROR";
872
- /** Error checking status */
873
- readonly STATUS_ERROR: "APTOS_STATUS_ERROR";
874
- /** Error calling Move function */
875
- readonly MOVE_CALL_ERROR: "APTOS_MOVE_CALL_ERROR";
876
- /** Unsupported token */
877
- readonly UNSUPPORTED_TOKEN: "APTOS_UNSUPPORTED_TOKEN";
878
- };
879
- /**
880
- * Type for Aptos error codes
881
- * Ensures type safety when using error codes
882
- */
883
- type AptosErrorCode = typeof APTOS_ERROR_CODES[keyof typeof APTOS_ERROR_CODES];
884
- /**
885
- * Stellar adapter error codes
886
- */
887
- declare const STELLAR_ERROR_CODES: {
888
- readonly MISSING_SIGNED_TRANSACTION: "STELLAR_MISSING_SIGNED_TRANSACTION";
889
- readonly GASLESS_TRANSACTION_ERROR: "STELLAR_GASLESS_TRANSACTION_ERROR";
890
- readonly STATUS_ERROR: "STELLAR_STATUS_ERROR";
891
- readonly HEALTH_ERROR: "STELLAR_HEALTH_ERROR";
892
- readonly INVALID_ADDRESS_FORMAT: "STELLAR_INVALID_ADDRESS_FORMAT";
893
- };
894
- /**
895
- * Generic API response structure
896
- * Used for all API responses with optional data payload
897
- *
898
- * @typeParam T - Type of the response data
899
- *
900
- * @example
901
- * ```typescript
902
- * const response: ApiResponse<TransferResult> = await api.transfer(data);
903
- * if (response.success && response.data) {
904
- * console.log('Transfer successful:', response.data.txHash);
905
- * }
906
- * ```
907
- */
908
- interface ApiResponse<T = any> {
909
- /** Indicates if request was successful */
910
- success: boolean;
911
- /** Response data (present on success) */
912
- data?: T;
913
- /** Error message (present on failure) */
914
- error?: string;
915
- /** Additional error details */
916
- details?: string[];
917
- /** Unique request identifier */
918
- requestId?: string;
919
- /** Error code for programmatic handling */
920
- errorCode?: string;
921
- /** Chain where request was made */
922
- chain?: SupportedChain;
923
- /** Response timestamp (ISO 8601) */
924
- timestamp?: string;
925
- /** Usage metadata from proxy worker (v2) */
926
- metadata?: UsageMetadata;
927
- }
928
- /**
929
- * SDK configuration for v2 - Proxy-based architecture
930
- *
931
- * @remarks
932
- * All requests route through proxy.smoothsend.xyz with API key authentication
933
- *
934
- * @example
935
- * ```typescript
936
- * const config: SmoothSendConfig = {
937
- * apiKey: 'no_gas_abc123...',
938
- * network: 'testnet',
939
- * timeout: 30000,
940
- * retries: 3
941
- * };
942
- * const sdk = new SmoothSendSDK(config);
943
- * ```
944
- */
945
- interface SmoothSendConfig {
946
- /** API key with no_gas_ prefix for authentication (required) */
947
- apiKey: string;
948
- /** Network to use: testnet or mainnet (default: testnet) */
949
- network?: 'testnet' | 'mainnet';
950
- /** Request timeout in milliseconds (default: 30000) */
951
- timeout?: number;
952
- /** Maximum retry attempts for failed requests (default: 3) */
953
- retries?: number;
954
- /** Additional headers to include in requests */
955
- customHeaders?: Record<string, string>;
956
- }
957
- /**
958
- * Usage metadata from proxy worker response headers
959
- * Contains rate limiting and usage tracking information
960
- *
961
- * @remarks
962
- * Attached to all transfer results and available via `getUsageStats()`
963
- *
964
- * @example
965
- * ```typescript
966
- * const result = await sdk.transfer(request, wallet);
967
- * console.log('Rate limit:', result.metadata?.rateLimit);
968
- * console.log('Monthly usage:', result.metadata?.monthly);
969
- *
970
- * // Check if approaching limits
971
- * if (parseInt(result.metadata.rateLimit.remaining) < 2) {
972
- * console.warn('Approaching rate limit!');
973
- * }
974
- * ```
975
- */
976
- interface UsageMetadata {
977
- /** Rate limit information (per minute) */
978
- rateLimit: {
979
- /** Maximum requests per minute */
980
- limit: string;
981
- /** Remaining requests this minute */
982
- remaining: string;
983
- /** When rate limit resets (ISO 8601 timestamp) */
984
- reset: string;
985
- };
986
- /** Monthly usage information */
987
- monthly: {
988
- /** Total monthly request limit */
989
- limit: string;
990
- /** Requests used this month */
991
- usage: string;
992
- /** Remaining requests this month */
993
- remaining: string;
994
- };
995
- /** Unique request identifier for debugging */
996
- requestId: string;
997
- }
998
- /**
999
- * Aptos wallet interface for sdk.transfer()
1000
- */
1001
- interface AptosWallet {
1002
- buildTransaction: (params: {
1003
- sender: string;
1004
- recipient: string;
1005
- amount: string;
1006
- coinType: string;
1007
- relayerFee: string;
1008
- }) => Promise<any>;
1009
- signTransaction: (transaction: any) => Promise<{
1010
- transactionBytes: number[];
1011
- authenticatorBytes: number[];
1012
- }>;
1013
- }
1014
- /**
1015
- * Stellar wallet interface for sdk.transfer()
1016
- * Use with Freighter, Stellar Wallets Kit, or any Stellar-compatible wallet
1017
- */
1018
- interface StellarWallet {
1019
- buildTransaction: (params: {
1020
- from: string;
1021
- to: string;
1022
- amount: string;
1023
- token: string;
1024
- }) => Promise<any>;
1025
- signTransaction: (transaction: any) => Promise<string>;
1026
- }
1027
- /**
1028
- * Transfer event types
1029
- * Emitted during transfer lifecycle for monitoring and debugging
1030
- */
1031
- interface TransferEvent {
1032
- /** Event type */
1033
- type: 'transfer_initiated' | 'transfer_signed' | 'transfer_submitted' | 'transfer_confirmed' | 'transfer_failed';
1034
- /** Event data (varies by type) */
1035
- data: any;
1036
- /** Event timestamp (Unix milliseconds) */
1037
- timestamp: number;
1038
- /** Chain where event occurred */
1039
- chain: SupportedChain;
1040
- }
1041
- /**
1042
- * Event listener callback function
1043
- * Called when transfer events are emitted
1044
- *
1045
- * @param event - Transfer event object
1046
- *
1047
- * @example
1048
- * ```typescript
1049
- * const listener: EventListener = (event) => {
1050
- * console.log(`Event: ${event.type} on ${event.chain}`);
1051
- * };
1052
- * sdk.addEventListener(listener);
1053
- * ```
1054
- */
1055
- type EventListener = (event: TransferEvent) => void;
1056
- /**
1057
- * Chain Adapter Interface - v2 Proxy Architecture
1058
- *
1059
- * @remarks
1060
- * All adapters route requests through proxy.smoothsend.xyz with API key authentication.
1061
- * The proxy handles relayer URL routing, so adapters no longer need direct relayer configuration.
1062
- *
1063
- * Key changes from v1:
1064
- * - Removed `config` property (relayer URLs handled by proxy)
1065
- * - Simplified to core methods: estimateFee, executeGaslessTransfer
1066
- * - Removed getQuote, prepareTransfer, getNonce, getTokenInfo (not needed for proxy flow)
1067
- * - Network parameter (testnet/mainnet) passed via HTTP headers, not method parameters
1068
- * - Client-side validation methods remain for address and amount validation
1069
- *
1070
- * Design rationale:
1071
- * - Consistent interface across all chains
1072
- * - Minimal surface area - only essential methods
1073
- * - Async by default for all I/O operations
1074
- * - Client-side validation done locally without network calls
1075
- * - Wallet libraries handle balance queries and transaction building
1076
- *
1077
- * @example
1078
- * ```typescript
1079
- * class MyChainAdapter implements IChainAdapter {
1080
- * readonly chain: SupportedChain = 'aptos-testnet';
1081
- *
1082
- * async estimateFee(request: TransferRequest): Promise<FeeEstimate> {
1083
- * // Implementation
1084
- * }
1085
- *
1086
- * async executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult> {
1087
- * // Implementation
1088
- * }
1089
- *
1090
- * // ... other methods
1091
- * }
1092
- * ```
1093
- */
1094
- interface IChainAdapter {
1095
- /** Chain identifier this adapter handles */
1096
- readonly chain: SupportedChain;
1097
- /**
1098
- * Estimate fee for a transfer
1099
- *
1100
- * @param request - Transfer request parameters
1101
- * @returns Fee estimate with relayer fee and gas information
1102
- * @throws {ValidationError} If request parameters are invalid
1103
- * @throws {NetworkError} If unable to reach proxy/relayer
1104
- *
1105
- * @example
1106
- * ```typescript
1107
- * const estimate = await adapter.estimateFee({
1108
- * from: '0x123...',
1109
- * to: '0x456...',
1110
- * token: 'USDC',
1111
- * amount: '1000000',
1112
- * chain: 'aptos-testnet'
1113
- * });
1114
- * console.log('Fee:', estimate.relayerFee);
1115
- * ```
1116
- */
1117
- estimateFee(request: TransferRequest): Promise<FeeEstimate>;
1118
- /**
1119
- * Execute a gasless transfer with signed transaction data
1120
- *
1121
- * @param signedData - Signed transfer data with serialized transaction
1122
- * @returns Transfer result with transaction hash and metadata
1123
- * @throws {AuthenticationError} If API key is invalid
1124
- * @throws {RateLimitError} If rate limit is exceeded
1125
- * @throws {ValidationError} If signed data is invalid
1126
- * @throws {NetworkError} If unable to reach proxy/relayer
1127
- *
1128
- * @example
1129
- * ```typescript
1130
- * const result = await adapter.executeGaslessTransfer({
1131
- * transactionBytes: [1, 2, 3, ...],
1132
- * authenticatorBytes: [4, 5, 6, ...],
1133
- * chain: 'aptos-testnet',
1134
- * network: 'testnet'
1135
- * });
1136
- * console.log('Transaction:', result.txHash);
1137
- * ```
1138
- */
1139
- executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
1140
- /**
1141
- * Get transaction status by hash
1142
- *
1143
- * @param txHash - Transaction hash to query
1144
- * @returns Transaction status information
1145
- * @throws {ValidationError} If transaction hash is invalid
1146
- * @throws {NetworkError} If unable to reach proxy/relayer
1147
- *
1148
- * @example
1149
- * ```typescript
1150
- * const status = await adapter.getTransactionStatus('0xabc123...');
1151
- * console.log('Status:', status);
1152
- * ```
1153
- */
1154
- getTransactionStatus(txHash: string): Promise<any>;
1155
- /**
1156
- * Check health status of the chain's relayer
1157
- *
1158
- * @returns Health response with status and version
1159
- * @throws {NetworkError} If unable to reach proxy/relayer
1160
- *
1161
- * @example
1162
- * ```typescript
1163
- * const health = await adapter.getHealth();
1164
- * console.log('Status:', health.status);
1165
- * ```
1166
- */
1167
- getHealth(): Promise<HealthResponse>;
1168
- /**
1169
- * Validate address format (client-side, no network call)
1170
- *
1171
- * @param address - Address to validate
1172
- * @returns true if address format is valid, false otherwise
1173
- *
1174
- * @example
1175
- * ```typescript
1176
- * const isValid = adapter.validateAddress('0x123...');
1177
- * if (!isValid) {
1178
- * console.error('Invalid address format');
1179
- * }
1180
- * ```
1181
- */
1182
- validateAddress(address: string): boolean;
1183
- /**
1184
- * Validate amount format (client-side, no network call)
1185
- *
1186
- * @param amount - Amount to validate (in smallest unit)
1187
- * @returns true if amount format is valid, false otherwise
1188
- *
1189
- * @example
1190
- * ```typescript
1191
- * const isValid = adapter.validateAmount('1000000');
1192
- * if (!isValid) {
1193
- * console.error('Invalid amount format');
1194
- * }
1195
- * ```
1196
- */
1197
- validateAmount(amount: string): boolean;
1198
- }
1199
-
1200
- declare class SmoothSendSDK {
1201
- private adapters;
1202
- private eventListeners;
1203
- private config;
1204
- private keyType;
1205
- private hasWarnedAboutSecretKey;
1206
- constructor(config: SmoothSendConfig);
1207
- /**
1208
- * Detect key type from API key prefix
1209
- * Supports pk_nogas_* (public), sk_nogas_* (secret), and no_gas_* (legacy)
1210
- */
1211
- private detectKeyType;
1212
- /**
1213
- * Check if running in browser environment
1214
- * Used for conditional warnings and Origin header logic
1215
- */
1216
- private isBrowserEnvironment;
1217
- /**
1218
- * Warn if secret key is used in browser environment
1219
- * Only warns once per SDK instance
1220
- */
1221
- private warnIfSecretKeyInBrowser;
1222
- /**
1223
- * Determine if Origin header should be included in requests
1224
- * Include Origin header only for public keys in browser environment
1225
- */
1226
- private shouldIncludeOrigin;
1227
- /**
1228
- * Get or create adapter for a specific chain on-demand
1229
- */
1230
- private getOrCreateAdapter;
1231
- addEventListener(listener: EventListener): void;
1232
- removeEventListener(listener: EventListener): void;
1233
- private emitEvent;
1234
- estimateFee(request: TransferRequest): Promise<FeeEstimate & {
1235
- metadata?: UsageMetadata;
1236
- }>;
1237
- /**
1238
- * Submit a signed Stellar transaction (XDR) for gasless relay.
1239
- * Use when you've already built and signed the transaction.
1240
- *
1241
- * @example
1242
- * const signedXdr = await stellarWallet.signTransaction(tx);
1243
- * const result = await sdk.submitStellarTransaction(signedXdr);
1244
- */
1245
- submitStellarTransaction(signedXdr: string): Promise<TransferResult>;
1246
- executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
1247
- /**
1248
- * Convenience method for complete transfer flow
1249
- * Works for both Aptos and Stellar - same 3-line API.
1250
- *
1251
- * @param request Transfer request with from, to, token, amount, chain
1252
- * @param wallet Aptos or Stellar wallet provider
1253
- * @returns Transfer result with transaction hash and usage metadata
1254
- *
1255
- * Aptos wallet: signTransaction returns { transactionBytes, authenticatorBytes }
1256
- * Stellar wallet: signTransaction returns string (signed XDR)
1257
- */
1258
- transfer(request: TransferRequest, wallet: AptosWallet | StellarWallet): Promise<TransferResult>;
1259
- private transferStellar;
1260
- /**
1261
- * Get transaction status for a specific transaction
1262
- * Routes through proxy to chain-specific status endpoint
1263
- *
1264
- * @param chain Chain where the transaction was executed
1265
- * @param txHash Transaction hash to query
1266
- * @returns Transaction status information
1267
- * @throws SmoothSendError if chain is not supported or status check fails
1268
- *
1269
- * @example
1270
- * ```typescript
1271
- * const status = await sdk.getTransactionStatus('aptos-testnet', '0x123...');
1272
- * console.log('Transaction status:', status);
1273
- * ```
1274
- */
1275
- getTransactionStatus(chain: SupportedChain, txHash: string): Promise<any>;
1276
- validateAddress(chain: SupportedChain, address: string): boolean;
1277
- validateAmount(chain: SupportedChain, amount: string): boolean;
1278
- /**
1279
- * Check proxy worker health status
1280
- * Routes directly to proxy's /health endpoint (not chain-specific)
1281
- *
1282
- * @returns Health response with status, version, and timestamp
1283
- * @throws NetworkError if proxy is unavailable
1284
- * @throws SmoothSendError for other errors
1285
- *
1286
- * @example
1287
- * ```typescript
1288
- * try {
1289
- * const health = await sdk.getHealth();
1290
- * console.log('Proxy status:', health.status);
1291
- * console.log('Version:', health.version);
1292
- * } catch (error) {
1293
- * if (error instanceof NetworkError) {
1294
- * console.error('Proxy unavailable. Please retry later.');
1295
- * }
1296
- * }
1297
- * ```
1298
- */
1299
- getHealth(): Promise<HealthResponse>;
1300
- /**
1301
- * Get list of supported chains (static list)
1302
- * For dynamic list from proxy, use getSupportedChainsFromProxy()
1303
- *
1304
- * @returns Array of supported chain identifiers
1305
- *
1306
- * @example
1307
- * ```typescript
1308
- * const chains = sdk.getSupportedChains();
1309
- * console.log('Supported chains:', chains);
1310
- * // Output: ['aptos-testnet', 'aptos-mainnet']
1311
- * ```
1312
- */
1313
- getSupportedChains(): SupportedChain[];
1314
- /**
1315
- * Get list of supported chains from proxy worker (dynamic)
1316
- * Queries the proxy for the current list of supported chains
1317
- *
1318
- * @returns Promise with array of chain information including status
1319
- * @throws SmoothSendError if unable to fetch chains from proxy
1320
- *
1321
- * @example
1322
- * ```typescript
1323
- * const chains = await sdk.getSupportedChainsFromProxy();
1324
- * chains.forEach(chain => {
1325
- * console.log(`${chain.name} (${chain.id}): ${chain.status}`);
1326
- * });
1327
- * ```
1328
- */
1329
- getSupportedChainsFromProxy(): Promise<Array<{
1330
- id: string;
1331
- name: string;
1332
- ecosystem: string;
1333
- network: string;
1334
- status: string;
1335
- }>>;
1336
- /**
1337
- * Check if a specific chain is currently supported
1338
- *
1339
- * @param chain Chain identifier to check
1340
- * @returns true if chain is supported, false otherwise
1341
- *
1342
- * @example
1343
- * ```typescript
1344
- * if (sdk.isChainSupported('aptos-testnet')) {
1345
- * console.log('Aptos testnet is supported');
1346
- * } else {
1347
- * console.log('Chain not supported');
1348
- * }
1349
- * ```
1350
- */
1351
- isChainSupported(chain: string): boolean;
1352
- /**
1353
- * Check health status of a specific chain's relayer
1354
- * Routes through proxy to chain-specific health endpoint
1355
- *
1356
- * @param chain Chain identifier to check
1357
- * @returns Health response for the specific chain
1358
- * @throws SmoothSendError if chain is not supported or health check fails
1359
- *
1360
- * @example
1361
- * ```typescript
1362
- * try {
1363
- * const health = await sdk.getChainHealth('aptos-testnet');
1364
- * console.log('Aptos testnet status:', health.status);
1365
- * } catch (error) {
1366
- * console.error('Chain health check failed:', error.message);
1367
- * }
1368
- * ```
1369
- */
1370
- getChainHealth(chain: SupportedChain): Promise<HealthResponse>;
1371
- /**
1372
- * Get current usage statistics without making a transfer
1373
- * Makes a lightweight health check request to retrieve usage metadata
1374
- *
1375
- * @returns Usage metadata with rate limit and monthly usage information
1376
- * @throws Error if unable to retrieve usage stats
1377
- *
1378
- * @example
1379
- * ```typescript
1380
- * const usage = await sdk.getUsageStats();
1381
- * console.log('Rate limit:', usage.rateLimit);
1382
- * console.log('Monthly usage:', usage.monthly);
1383
- * console.log('Request ID:', usage.requestId);
1384
- *
1385
- * // Check if approaching limits
1386
- * if (parseInt(usage.rateLimit.remaining) < 2) {
1387
- * console.warn('Approaching rate limit!');
1388
- * }
1389
- * ```
1390
- */
1391
- getUsageStats(): Promise<UsageMetadata>;
1392
- /**
1393
- * Extract request ID from a transfer result for debugging and support
1394
- *
1395
- * @param result Transfer result from executeGaslessTransfer or transfer
1396
- * @returns Request ID if available, undefined otherwise
1397
- *
1398
- * @example
1399
- * ```typescript
1400
- * const result = await sdk.executeGaslessTransfer(signedData);
1401
- * const requestId = sdk.getRequestId(result);
1402
- * if (requestId) {
1403
- * console.log('Request ID for support:', requestId);
1404
- * }
1405
- * ```
1406
- */
1407
- getRequestId(result: TransferResult): string | undefined;
1408
- /**
1409
- * Check if approaching rate limit based on transfer result metadata
1410
- *
1411
- * @param result Transfer result with metadata
1412
- * @param threshold Percentage threshold (0-100) to consider as "approaching" (default: 20)
1413
- * @returns true if remaining requests are below threshold percentage
1414
- *
1415
- * @example
1416
- * ```typescript
1417
- * const result = await sdk.transfer(request, wallet);
1418
- * if (sdk.isApproachingRateLimit(result)) {
1419
- * console.warn('Approaching rate limit, consider slowing down requests');
1420
- * }
1421
- * ```
1422
- */
1423
- isApproachingRateLimit(result: TransferResult, threshold?: number): boolean;
1424
- /**
1425
- * Check if approaching monthly usage limit based on transfer result metadata
1426
- *
1427
- * @param result Transfer result with metadata
1428
- * @param threshold Percentage threshold (0-100) to consider as "approaching" (default: 90)
1429
- * @returns true if monthly usage is above threshold percentage
1430
- *
1431
- * @example
1432
- * ```typescript
1433
- * const result = await sdk.transfer(request, wallet);
1434
- * if (sdk.isApproachingMonthlyLimit(result)) {
1435
- * console.warn('Approaching monthly limit, consider upgrading plan');
1436
- * }
1437
- * ```
1438
- */
1439
- isApproachingMonthlyLimit(result: TransferResult, threshold?: number): boolean;
1440
- /**
1441
- * Check if a chain belongs to a specific ecosystem
1442
- */
1443
- getChainEcosystem(chain: SupportedChain): ChainEcosystem;
1444
- /**
1445
- * Get list of supported chains (static method)
1446
- * Can be called without instantiating the SDK
1447
- *
1448
- * @returns Array of supported chain identifiers
1449
- *
1450
- * @example
1451
- * ```typescript
1452
- * const chains = SmoothSendSDK.getSupportedChains();
1453
- * console.log('Supported chains:', chains);
1454
- * ```
1455
- */
1456
- static getSupportedChains(): SupportedChain[];
1457
- }
1458
-
1459
- /**
1460
- * SmoothSend Transaction Submitter
1461
- *
1462
- * A TransactionSubmitter implementation that integrates with the Aptos Wallet Adapter
1463
- * to enable gasless transactions via SmoothSend's relayer network.
1464
- *
1465
- * @example
1466
- * ```typescript
1467
- * import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
1468
- * import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react';
1469
- *
1470
- * // Create the transaction submitter
1471
- * const transactionSubmitter = new SmoothSendTransactionSubmitter({
1472
- * apiKey: 'pk_nogas_your_api_key_here',
1473
- * network: 'testnet'
1474
- * });
1475
- *
1476
- * // Use in your wallet provider - that's it!
1477
- * <AptosWalletAdapterProvider
1478
- * dappConfig={{
1479
- * network: Network.TESTNET,
1480
- * transactionSubmitter: transactionSubmitter
1481
- * }}
1482
- * >
1483
- * <App />
1484
- * </AptosWalletAdapterProvider>
1485
- * ```
1486
- */
1487
-
1488
- /**
1489
- * Configuration options for SmoothSendTransactionSubmitter
1490
- */
1491
- interface SmoothSendTransactionSubmitterConfig {
1492
- /**
1493
- * Your SmoothSend API key
1494
- * - Use `pk_nogas_*` for frontend applications (CORS protected)
1495
- * - Use `sk_nogas_*` for backend applications only
1496
- */
1497
- apiKey: string;
1498
- /**
1499
- * Network to use
1500
- * @default 'testnet'
1501
- */
1502
- network?: 'testnet' | 'mainnet';
1503
- /**
1504
- * Gateway URL (usually you don't need to change this)
1505
- * @default 'https://proxy.smoothsend.xyz'
1506
- */
1507
- gatewayUrl?: string;
1508
- /**
1509
- * Request timeout in milliseconds
1510
- * @default 30000
1511
- */
1512
- timeout?: number;
1513
- /**
1514
- * A function that returns a captcha token (e.g. from Cloudflare Turnstile or reCAPTCHA).
1515
- * Called before each transaction if the project requires captcha verification.
1516
- * Return null/undefined to skip captcha.
1517
- */
1518
- getCaptchaToken?: () => Promise<string | null | undefined>;
1519
- /**
1520
- * Enable debug logging
1521
- * @default false
1522
- */
1523
- debug?: boolean;
1524
- /**
1525
- * Enable session key mode — user signs once, all subsequent transactions
1526
- * are signed silently by an in-memory session key. Zero wallet popups after setup.
1527
- *
1528
- * Uses Aptos Account Abstraction (AIP-103 Permissioned Signers) — enforced on-chain.
1529
- * Live on mainnet and testnet (as of April 2025).
1530
- * SmoothSend pays gas for the one-time session setup transaction too.
1531
- *
1532
- * @default false
1533
- *
1534
- * @example
1535
- * ```typescript
1536
- * const smoothSend = new SmoothSendTransactionSubmitter({
1537
- * apiKey: 'pk_nogas_xxx',
1538
- * network: 'mainnet',
1539
- * session: true,
1540
- * });
1541
- * ```
1542
- */
1543
- session?: boolean;
1544
- /**
1545
- * How long the session key stays valid.
1546
- * Format: number + unit (s, m, h, d)
1547
- * Use "never" for client-side indefinite session validity.
1548
- * @default '24h'
1549
- */
1550
- sessionDuration?: string;
1551
- }
1552
- /**
1553
- * TransactionSubmitter interface compatible with @aptos-labs/ts-sdk v2.x
1554
- * This interface allows the SmoothSendTransactionSubmitter to work as a drop-in
1555
- * replacement for the default transaction submitter in the Aptos Wallet Adapter.
1556
- */
1557
- interface TransactionSubmitter {
1558
- submitTransaction(args: {
1559
- aptosConfig: AptosConfig;
1560
- transaction: AnyRawTransaction;
1561
- senderAuthenticator: AccountAuthenticator;
1562
- feePayerAuthenticator?: AccountAuthenticator;
1563
- additionalSignersAuthenticators?: Array<AccountAuthenticator>;
1564
- pluginParams?: Record<string, unknown>;
1565
- }): Promise<PendingTransactionResponse>;
1566
- }
1567
- /**
1568
- * SmoothSend Transaction Submitter
1569
- *
1570
- * Implements the TransactionSubmitter interface to enable gasless transactions
1571
- * through the Aptos Wallet Adapter. Simply pass this to your AptosWalletAdapterProvider
1572
- * and all transactions will automatically be submitted as gasless through SmoothSend.
1573
- */
1574
- declare class SmoothSendTransactionSubmitter implements TransactionSubmitter {
1575
- private readonly apiKey;
1576
- private readonly network;
1577
- private readonly gatewayUrl;
1578
- private readonly timeout;
1579
- private readonly getCaptchaToken?;
1580
- private readonly debug;
1581
- readonly sessionEnabled: boolean;
1582
- private readonly sessionDuration;
1583
- private _session;
1584
- constructor(config: SmoothSendTransactionSubmitterConfig);
1585
- /**
1586
- * Whether a valid session is currently active.
1587
- */
1588
- hasSession(): boolean;
1589
- /**
1590
- * Create a session key for the given master account.
1591
- * Called once by useSmoothSend when session: true and no session exists.
1592
- * SmoothSend pays gas for the setup transaction.
1593
- *
1594
- * @param masterAccount - The user's wallet account (from wallet adapter)
1595
- */
1596
- createSession(masterAccount: Account): Promise<void>;
1597
- private isPermissionedSignerEnabled;
1598
- private signSenderAuthenticator;
1599
- /**
1600
- * Submit a transaction using the active session key — no wallet popup.
1601
- * Called by useSmoothSend after session is established.
1602
- */
1603
- submitWithSession(functionName: `${string}::${string}::${string}`, functionArguments?: any[], typeArguments?: string[]): Promise<PendingTransactionResponse>;
1604
- private _parseDuration;
1605
- /**
1606
- * Submit a transaction through SmoothSend's gasless relayer
1607
- *
1608
- * This method is called automatically by the Aptos Wallet Adapter when
1609
- * you use signAndSubmitTransaction. The transaction is submitted to
1610
- * SmoothSend's relayer which sponsors the gas fees.
1611
- */
1612
- submitTransaction(args: {
1613
- aptosConfig: AptosConfig;
1614
- transaction: AnyRawTransaction;
1615
- senderAuthenticator: AccountAuthenticator;
1616
- feePayerAuthenticator?: AccountAuthenticator;
1617
- additionalSignersAuthenticators?: Array<AccountAuthenticator>;
1618
- pluginParams?: Record<string, unknown>;
1619
- }): Promise<PendingTransactionResponse>;
1620
- /**
1621
- * Resolve the effective network from aptosConfig.
1622
- * aptosConfig.network is the source of truth set by AptosWalletAdapterProvider.
1623
- */
1624
- private resolveNetwork;
1625
- /**
1626
- * Make an HTTP request to the SmoothSend gateway
1627
- */
1628
- private makeRequest;
1629
- private sponsoredFunctionsCache;
1630
- private sponsoredFunctionsCacheAt;
1631
- private readonly SPONSORED_CACHE_TTL;
1632
- /**
1633
- * Fetch the list of sponsored functions for this API key's project.
1634
- * Results are cached for 5 minutes. Returns ['*'] if all functions are sponsored.
1635
- */
1636
- getSponsoredFunctions(): Promise<string[]>;
1637
- /**
1638
- * Check if a specific function is sponsored for gasless execution.
1639
- * @param functionName - Full function identifier, e.g. "0x123::module::function"
1640
- */
1641
- isSponsored(functionName: string): Promise<boolean>;
1642
- /**
1643
- */
1644
- getConfig(): Readonly<SmoothSendTransactionSubmitterConfig>;
1645
- }
1646
- /**
1647
- * Create a SmoothSend transaction submitter with minimal configuration
1648
- *
1649
- * @example
1650
- * ```typescript
1651
- * const submitter = createSmoothSendSubmitter('pk_nogas_your_key');
1652
- * ```
1653
- */
1654
- declare function createSmoothSendSubmitter(apiKey: string, options?: Partial<Omit<SmoothSendTransactionSubmitterConfig, 'apiKey'>>): SmoothSendTransactionSubmitter;
1655
-
1656
- /**
1657
- * useSmoothSend — React hook for automatic gasless / user-pays-gas routing
1658
- *
1659
- * Drop-in replacement for useWallet()'s signAndSubmitTransaction.
1660
- * Fetches the project's sponsored-functions list from the gateway on mount
1661
- * and routes each transaction automatically:
1662
- * - Function in allowlist → fee-payer gasless path via SmoothSend
1663
- * - Function not in allowlist → regular wallet submission (user pays gas)
1664
- *
1665
- * When submitter has session: true, the first transaction triggers a one-time
1666
- * wallet sign to register a session key on-chain. Every transaction after that
1667
- * is signed silently — zero wallet popups.
1668
- *
1669
- * Requires: react >=17, @aptos-labs/wallet-adapter-react >=3, @aptos-labs/ts-sdk >=1
1670
- *
1671
- * @example
1672
- * ```tsx
1673
- * // Replace useWallet() with useSmoothSend() where you submit transactions.
1674
- * // No other changes needed.
1675
- *
1676
- * const { signAndSubmitTransaction } = useSmoothSend(submitter);
1677
- * await signAndSubmitTransaction({ data: { function: '0x1::coin::transfer', functionArguments: [to, amount] } });
1678
- * ```
1679
- */
1680
-
1681
- interface UseSmoothSendResult {
1682
- /**
1683
- * Smart signAndSubmitTransaction — same signature as the wallet adapter's version.
1684
- * Sponsored functions go gasless via SmoothSend; others fall back to user-pays-gas.
1685
- * With session: true, zero wallet popups after the first transaction.
1686
- */
1687
- signAndSubmitTransaction: (input: {
1688
- data: any;
1689
- options?: any;
1690
- }) => Promise<any>;
1691
- /**
1692
- * Whether a session key is currently active (only relevant when session: true).
1693
- * Updates reactively when session is created or expires.
1694
- */
1695
- hasSession: boolean;
1696
- }
1697
- declare function useSmoothSend(submitter: SmoothSendTransactionSubmitter): UseSmoothSendResult;
1698
-
1699
- interface CreateSessionOptions {
1700
- /**
1701
- * The master account that owns the Aptos address.
1702
- * Can be a KeylessAccount (Google/Apple login), Ed25519Account, or any Account
1703
- * that implements the Aptos Account interface.
1704
- *
1705
- * @example keylessAccount from aptos.deriveKeylessAccount(...)
1706
- * @example Account.fromPrivateKey({ privateKey })
1707
- */
1708
- signer: Account;
1709
- /**
1710
- * How long the session should stay valid.
1711
- * Format: number + unit (s = seconds, m = minutes, h = hours, d = days)
1712
- * @example '2h' | '24h' | '7d' | 'never'
1713
- */
1714
- expiresIn: string;
1715
- /**
1716
- * Network to use. Inferred from submitter if not provided.
1717
- */
1718
- network?: 'testnet' | 'mainnet';
1719
- }
1720
- interface SessionInfo {
1721
- /** The user's main account address — sender for all transactions */
1722
- masterAddress: string;
1723
- /** The temporary session key address (for debugging / display) */
1724
- sessionKeyAddress: string;
1725
- /** When this session expires (Unix timestamp in ms) */
1726
- expiresAt: number;
1727
- /** Network this session operates on */
1728
- network: 'testnet' | 'mainnet';
1729
- }
1730
- interface SubmitResult {
1731
- hash: string;
1732
- }
1733
- /**
1734
- * A session that lets your app submit transactions on behalf of a user
1735
- * without any wallet popup after the initial one-time setup.
1736
- *
1737
- * Uses Aptos AIP-103 Permissioned Signers — authorization is enforced
1738
- * on-chain by `0x1::permissioned_delegation`. No custom Move contract needed.
1739
- *
1740
- * @example
1741
- * // 1. One-time setup (user signs once — can be keyless/Google login)
1742
- * const session = await SmoothSendSession.create({
1743
- * signer: keylessAccount,
1744
- * expiresIn: '24h',
1745
- * }, submitter)
1746
- *
1747
- * // 2. Every action after — zero popups, zero gas
1748
- * await session.submit('0xgame::player::move', ['north'])
1749
- * await session.submit('0xgame::player::attack', [enemyId])
1750
- */
1751
- declare class SmoothSendSession {
1752
- private readonly sessionAccount;
1753
- private readonly abstractedAccount;
1754
- private readonly masterAddress;
1755
- private readonly expiresAtMs;
1756
- private readonly submitter;
1757
- private readonly aptosClient;
1758
- private readonly _network;
1759
- private constructor();
1760
- /**
1761
- * Create a new session.
1762
- *
1763
- * Registers the session key on-chain via
1764
- * `0x1::permissioned_delegation::add_permissioned_handle`.
1765
- * SmoothSend pays the gas for this setup transaction too.
1766
- *
1767
- * After this returns, the user never needs to approve anything again
1768
- * until the session expires or is revoked.
1769
- */
1770
- static create(options: CreateSessionOptions, submitter: SmoothSendTransactionSubmitter): Promise<SmoothSendSession>;
1771
- /**
1772
- * Submit a transaction silently — no wallet popup, zero gas.
1773
- *
1774
- * The transaction sender on-chain is still the user's main address.
1775
- * The session key signs it, and `permissioned_delegation::authenticate`
1776
- * validates the authorization at the VM level.
1777
- *
1778
- * @param functionName Full Move function identifier e.g. '0xgame::player::move'
1779
- * @param functionArguments Arguments matching the Move function signature
1780
- * @param typeArguments Optional type arguments for generic functions
1781
- *
1782
- * @example
1783
- * await session.submit('0xgame::player::move', ['north'])
1784
- * await session.submit('0x1::coin::transfer', [recipientAddr, 1000000n])
1785
- */
1786
- submit(functionName: `${string}::${string}::${string}`, functionArguments?: any[], typeArguments?: string[]): Promise<SubmitResult>;
1787
- /**
1788
- * Whether this session is still valid (not yet expired).
1789
- */
1790
- isValid(): boolean;
1791
- /**
1792
- * Milliseconds until this session expires. Returns 0 if already expired.
1793
- */
1794
- expiresInMs(): number;
1795
- /**
1796
- * Session metadata — useful for display or debugging.
1797
- */
1798
- get info(): SessionInfo;
1799
- }
1800
-
1801
- /**
1802
- * Script Composer Client
1803
- *
1804
- * Wrapper for Script Composer gasless transactions.
1805
- * Use this for token transfers on mainnet with free tier (fee deducted from token).
1806
- *
1807
- * @remarks
1808
- * Script Composer builds a batched transaction that:
1809
- * 1. Withdraws (amount + fee) from sender
1810
- * 2. Deposits amount to recipient
1811
- * 3. Deposits fee to treasury
1812
- *
1813
- * This allows gasless transactions where the fee is paid in the token being transferred.
1814
- *
1815
- * @example
1816
- * ```typescript
1817
- * import { ScriptComposerClient } from '@smoothsend/aptos-sdk';
1818
- *
1819
- * const client = new ScriptComposerClient({
1820
- * apiKey: 'pk_nogas_xxx',
1821
- * network: 'mainnet'
1822
- * });
1823
- *
1824
- * // Step 1: Build transaction (fee calculated automatically)
1825
- * const { transactionBytes, fee, totalAmount } = await client.buildTransfer({
1826
- * sender: wallet.address,
1827
- * recipient: '0x123...',
1828
- * amount: '1000000', // 1 USDC (6 decimals)
1829
- * assetType: '0x...::usdc::USDC',
1830
- * decimals: 6,
1831
- * symbol: 'USDC'
1832
- * });
1833
- *
1834
- * // Step 2: Sign with wallet
1835
- * const signedTx = await wallet.signTransaction(transactionBytes);
1836
- *
1837
- * // Step 3: Submit
1838
- * const result = await client.submitSignedTransaction({
1839
- * transactionBytes: signedTx.transactionBytes,
1840
- * authenticatorBytes: signedTx.authenticatorBytes
1841
- * });
1842
- *
1843
- * console.log('Tx:', result.txHash);
1844
- * ```
1845
- */
1846
- /**
1847
- * Configuration for Script Composer Client
1848
- */
1849
- interface ScriptComposerConfig {
1850
- /** API key for authentication (pk_nogas_* or sk_nogas_*) */
1851
- apiKey: string;
1852
- /** Network to use: 'testnet' or 'mainnet' */
1853
- network: 'testnet' | 'mainnet';
1854
- /** Custom proxy URL (optional, defaults to proxy.smoothsend.xyz) */
1855
- proxyUrl?: string;
1856
- /** Request timeout in milliseconds (default: 30000) */
1857
- timeout?: number;
1858
- /** Enable debug logging */
1859
- debug?: boolean;
1860
- }
1861
- /**
1862
- * Parameters for building a Script Composer transfer
1863
- */
1864
- interface BuildTransferParams {
1865
- /** Sender's wallet address */
1866
- sender: string;
1867
- /** Recipient's wallet address */
1868
- recipient: string;
1869
- /** Amount in smallest units (e.g., 1000000 for 1 USDC) */
1870
- amount: string;
1871
- /** Full asset type address (e.g., '0x...::usdc::USDC') */
1872
- assetType: string;
1873
- /** Token decimals (e.g., 6 for USDC, 8 for APT) */
1874
- decimals: number;
1875
- /** Token symbol (e.g., 'USDC', 'APT') */
1876
- symbol: string;
1877
- }
1878
- /**
1879
- * Result from building a transfer
1880
- */
1881
- interface BuildTransferResult {
1882
- /** Success status */
1883
- success: boolean;
1884
- /** Request ID for tracking */
1885
- requestId: string;
1886
- /** Serialized transaction bytes for wallet signing */
1887
- transactionBytes: number[];
1888
- /** Transaction details */
1889
- transaction: {
1890
- sender: string;
1891
- recipient: string;
1892
- amount: string;
1893
- assetType: string;
1894
- network: string;
1895
- };
1896
- /** Fee amount in smallest units */
1897
- fee: string;
1898
- /** Total amount (amount + fee) in smallest units */
1899
- totalAmount: string;
1900
- /** Fee breakdown with formatted values */
1901
- feeBreakdown: {
1902
- amount: string;
1903
- fee: string;
1904
- totalAmount: string;
1905
- formatted: {
1906
- amount: string;
1907
- fee: string;
1908
- totalAmount: string;
1909
- };
1910
- pricing: {
1911
- tier: string;
1912
- zeroFees: boolean;
1913
- feeInUsd: number;
1914
- tokenPrice: number | null;
1915
- description: string;
1916
- };
1917
- };
1918
- }
1919
- /**
1920
- * Parameters for submitting a signed transaction
1921
- */
1922
- interface SubmitSignedTransactionParams {
1923
- /** Serialized transaction bytes (from wallet signing) */
1924
- transactionBytes: number[];
1925
- /** Serialized authenticator bytes (from wallet signing) */
1926
- authenticatorBytes: number[];
1927
- }
1928
- /**
1929
- * Result from submitting a transaction
1930
- */
1931
- interface SubmitTransactionResult {
1932
- /** Success status */
1933
- success: boolean;
1934
- /** Request ID for tracking */
1935
- requestId: string;
1936
- /** Transaction hash */
1937
- txHash: string;
1938
- /** Gas used */
1939
- gasUsed?: string;
1940
- /** VM status */
1941
- vmStatus?: string;
1942
- /** Sender address */
1943
- sender?: string;
1944
- }
1945
- /**
1946
- * Fee estimation result
1947
- */
1948
- interface FeeEstimateResult {
1949
- /** Success status */
1950
- success: boolean;
1951
- /** Request ID for tracking */
1952
- requestId: string;
1953
- /** Fee estimation details */
1954
- estimation: {
1955
- /** Amount in smallest units */
1956
- amount: string;
1957
- /** Fee in smallest units */
1958
- fee: string;
1959
- /** Total amount in smallest units */
1960
- totalAmount: string;
1961
- /** Formatted values for display */
1962
- formatted: {
1963
- amount: string;
1964
- fee: string;
1965
- totalAmount: string;
1966
- };
1967
- /** Pricing information */
1968
- pricing: {
1969
- tier: string;
1970
- zeroFees: boolean;
1971
- feeInUsd: number;
1972
- tokenPrice: number | null;
1973
- description: string;
1974
- };
1975
- /** Usage information */
1976
- usage: {
1977
- monthlyLimit: number;
1978
- usedThisMonth: number;
1979
- remaining: number;
1980
- };
1981
- };
1982
- }
1983
- /**
1984
- * Script Composer Client
1985
- *
1986
- * For gasless token transfers with fee deducted from the token.
1987
- * Use this on mainnet with free tier, or anytime you want fee-in-token.
1988
- */
1989
- declare class ScriptComposerClient {
1990
- private httpClient;
1991
- private config;
1992
- constructor(config: ScriptComposerConfig);
1993
- private isBrowser;
1994
- private log;
1995
- /**
1996
- * Estimate fee for a transfer without building the transaction
1997
- *
1998
- * @param params Transfer parameters
1999
- * @returns Fee estimation with pricing details
2000
- */
2001
- estimateFee(params: BuildTransferParams): Promise<FeeEstimateResult>;
2002
- /**
2003
- * Build a gasless transfer transaction
2004
- *
2005
- * Returns unsigned transaction bytes that must be signed by the user's wallet.
2006
- * The fee will be deducted from the token being transferred.
2007
- *
2008
- * @param params Transfer parameters
2009
- * @returns Transaction bytes for signing and fee details
2010
- */
2011
- buildTransfer(params: BuildTransferParams): Promise<BuildTransferResult>;
2012
- /**
2013
- * Submit a signed transaction
2014
- *
2015
- * After the user signs the transaction bytes returned by buildTransfer(),
2016
- * use this method to submit the signed transaction.
2017
- *
2018
- * @param params Signed transaction bytes
2019
- * @returns Transaction result with hash
2020
- */
2021
- submitSignedTransaction(params: SubmitSignedTransactionParams): Promise<SubmitTransactionResult>;
2022
- /**
2023
- * Complete transfer flow: build, sign, and submit
2024
- *
2025
- * Convenience method that handles the entire flow.
2026
- * Requires a wallet that can sign transactions.
2027
- *
2028
- * @param params Transfer parameters
2029
- * @param wallet Wallet with signTransaction method
2030
- * @returns Transaction result
2031
- *
2032
- * @example
2033
- * ```typescript
2034
- * const result = await client.transfer({
2035
- * sender: wallet.address,
2036
- * recipient: '0x123...',
2037
- * amount: '1000000',
2038
- * assetType: USDC_ADDRESS,
2039
- * decimals: 6,
2040
- * symbol: 'USDC'
2041
- * }, wallet);
2042
- * ```
2043
- */
2044
- transfer(params: BuildTransferParams, wallet: {
2045
- signTransaction: (txBytes: number[]) => Promise<{
2046
- transactionBytes: number[];
2047
- authenticatorBytes: number[];
2048
- }>;
2049
- }): Promise<SubmitTransactionResult>;
2050
- /**
2051
- * Get current network
2052
- */
2053
- getNetwork(): 'testnet' | 'mainnet';
2054
- /**
2055
- * Set network
2056
- */
2057
- setNetwork(network: 'testnet' | 'mainnet'): void;
2058
- }
2059
- /**
2060
- * Create a Script Composer client (convenience function)
2061
- */
2062
- declare function createScriptComposerClient(config: ScriptComposerConfig): ScriptComposerClient;
2063
-
2064
- /**
2065
- * True Gasless Client
2066
- *
2067
- * Designed for server-side (backend) environments to securely build, sign,
2068
- * and submit 100% sponsored gasless transactions using a Secret Key.
2069
- *
2070
- * @example
2071
- * ```typescript
2072
- * import { TrueGaslessClient } from '@smoothsend/sdk';
2073
- * import { Account } from '@aptos-labs/ts-sdk';
2074
- *
2075
- * const backendWallet = Account.fromPrivateKey({ privateKey: '...' });
2076
- * const client = new TrueGaslessClient({ apiKey: 'sk_nogas_...', network: 'mainnet' });
2077
- *
2078
- * const result = await client.execute({
2079
- * senderAccount: backendWallet,
2080
- * payload: {
2081
- * function: "0x123::my_module::mint_nft",
2082
- * functionArguments: []
2083
- * }
2084
- * });
2085
- *
2086
- * console.log("Gasless NFT Minted!", result.txHash);
2087
- * ```
2088
- */
2089
-
2090
- interface TrueGaslessConfig {
2091
- /** API key for authentication (must be sk_nogas_* for backend) */
2092
- apiKey: string;
2093
- /** Network to use: 'testnet' | 'mainnet' */
2094
- network: 'testnet' | 'mainnet';
2095
- /** Custom proxy URL (optional) */
2096
- proxyUrl?: string;
2097
- /** Request timeout in milliseconds */
2098
- timeout?: number;
2099
- /** Enable debug logging */
2100
- debug?: boolean;
2101
- }
2102
- interface ExecuteGaslessParams {
2103
- /** The backend sender wallet identity */
2104
- senderAccount: Account;
2105
- /** Raw transaction payload to execute */
2106
- payload: InputGenerateTransactionPayloadData;
2107
- }
2108
- interface ExecuteGaslessResult {
2109
- success: boolean;
2110
- requestId?: string;
2111
- txHash?: string;
2112
- gasUsed?: string;
2113
- vmStatus?: string;
2114
- sender?: string;
2115
- }
2116
- declare class TrueGaslessClient {
2117
- private httpClient;
2118
- private config;
2119
- private aptos;
2120
- constructor(config: TrueGaslessConfig);
2121
- private log;
2122
- /**
2123
- * Builds, signs (as sender), and relays an arbitrary payload for complete sponsorship.
2124
- */
2125
- execute(params: ExecuteGaslessParams): Promise<ExecuteGaslessResult>;
2126
- /**
2127
- * Expose the core Aptos instance to allow backend developers to access chain state if needed
2128
- */
2129
- getAptosClient(): Aptos;
2130
- }
2131
- /**
2132
- * Helper to initialize TrueGaslessClient
2133
- */
2134
- declare function createTrueGaslessClient(config: TrueGaslessConfig): TrueGaslessClient;
2135
-
2136
- /**
2137
- * Aptos Multi-Chain Adapter - v2 Proxy Architecture
2138
- * Handles all Aptos chains (aptos-testnet, aptos-mainnet)
2139
- * Routes all requests through proxy.smoothsend.xyz with API key authentication
2140
- * Supports Aptos-specific features like gasless transactions and Move-based contracts
2141
- */
2142
- declare class AptosAdapter implements IChainAdapter {
2143
- readonly chain: SupportedChain;
2144
- readonly config: ChainConfig;
2145
- private httpClient;
2146
- private apiKey;
2147
- private network;
2148
- constructor(chain: SupportedChain, config: ChainConfig, apiKey: string, network?: 'testnet' | 'mainnet', includeOrigin?: boolean);
2149
- /**
2150
- * Build API path for proxy worker routing to Aptos relayer
2151
- * All requests route through /api/v1/relayer/aptos/* endpoints
2152
- */
2153
- private getApiPath;
2154
- /**
2155
- * Update network parameter for subsequent requests
2156
- * Network is passed via X-Network header to proxy worker
2157
- */
2158
- setNetwork(network: 'testnet' | 'mainnet'): void;
2159
- /**
2160
- * Get current network
2161
- */
2162
- getNetwork(): 'testnet' | 'mainnet';
2163
- /**
2164
- * Estimate fee for a transfer (v2 interface method)
2165
- * Routes through proxy: POST /api/v1/relayer/aptos/quote
2166
- */
2167
- estimateFee(request: TransferRequest): Promise<FeeEstimate>;
2168
- /**
2169
- * Execute gasless transfer (v2 interface method)
2170
- * Routes through proxy: POST /api/v1/relayer/aptos/execute
2171
- */
2172
- executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
2173
- /**
2174
- * Get quote for a transfer (legacy method, kept for backward compatibility)
2175
- * Routes through proxy: POST /api/v1/relayer/aptos/quote
2176
- */
2177
- getQuote(request: TransferRequest): Promise<TransferQuote>;
2178
- prepareTransfer(request: TransferRequest, quote: TransferQuote): Promise<SignatureData>;
2179
- executeTransfer(signedData: SignedTransferData): Promise<TransferResult>;
2180
- getBalance(address: string, token?: string): Promise<TokenBalance[]>;
2181
- getTokenInfo(token: string): Promise<TokenInfo>;
2182
- getNonce(address: string): Promise<string>;
2183
- getTransactionStatus(txHash: string): Promise<any>;
2184
- /**
2185
- * Get health status of Aptos relayer through proxy
2186
- * Routes through proxy: GET /api/v1/relayer/aptos/health
2187
- */
2188
- getHealth(): Promise<HealthResponse>;
2189
- validateAddress(address: string): boolean;
2190
- validateAmount(amount: string): boolean;
2191
- /**
2192
- * Get Aptos token address from symbol
2193
- * Mirrors aptosrelayer/config/chains.json
2194
- */
2195
- private getAptosTokenAddress;
2196
- /**
2197
- * Build Aptos explorer URL for transaction
2198
- */
2199
- private buildAptosExplorerUrl;
2200
- /**
2201
- * Validate serialized transaction data for proxy worker
2202
- * @param signedData The signed transfer data to validate
2203
- */
2204
- private validateSerializedTransactionData;
2205
- /**
2206
- * Enhanced address validation with detailed error messages
2207
- * @param address The address to validate
2208
- * @returns true if valid, throws error if invalid
2209
- */
2210
- validateAddressStrict(address: string): boolean;
2211
- /**
2212
- * Verify that a public key corresponds to an expected address
2213
- * This mirrors the enhanced verification in the relayer
2214
- * @param publicKey The public key to verify
2215
- * @param expectedAddress The expected address
2216
- * @returns true if they match
2217
- */
2218
- verifyPublicKeyAddress(publicKey: string, expectedAddress: string): Promise<boolean>;
2219
- /**
2220
- * Enhanced transaction preparation with better signature data structure
2221
- * @param request Transfer request
2222
- * @param quote Transfer quote
2223
- * @returns Signature data with enhanced structure
2224
- */
2225
- prepareTransferEnhanced(request: TransferRequest, quote: TransferQuote): Promise<SignatureData & {
2226
- metadata: any;
2227
- }>;
2228
- /**
2229
- * Aptos-specific Move contract interaction
2230
- */
2231
- callMoveFunction(functionName: string, args: any[]): Promise<any>;
2232
- }
2233
-
2234
- /**
2235
- * Configuration for HTTP client
2236
- */
2237
- interface HttpClientConfig {
2238
- apiKey: string;
2239
- network?: 'testnet' | 'mainnet';
2240
- timeout?: number;
2241
- retries?: number;
2242
- customHeaders?: Record<string, string>;
2243
- includeOrigin?: boolean;
2244
- /** Override the default proxy base URL (e.g. for self-hosted relayers) */
2245
- baseUrl?: string;
2246
- }
2247
- /**
2248
- * HTTP Client for proxy worker integration
2249
- * Handles authentication, rate limiting, usage tracking, and retry logic
2250
- */
2251
- declare class HttpClient {
2252
- private client;
2253
- private apiKey?;
2254
- private network;
2255
- private maxRetries;
2256
- private baseURL;
2257
- private isProxyMode;
2258
- private includeOrigin;
2259
- /**
2260
- * Constructor supports both old (baseURL, timeout) and new (config object) patterns
2261
- * for backward compatibility during migration
2262
- */
2263
- constructor(configOrBaseURL: HttpClientConfig | string, timeout?: number);
2264
- /**
2265
- * Extract usage metadata from response headers (proxy mode only)
2266
- * Uses USAGE_HEADERS constants for consistency across systems
2267
- */
2268
- private extractMetadata;
2269
- /**
2270
- * Determine if an error should be retried
2271
- */
2272
- private shouldRetry;
2273
- /**
2274
- * Calculate exponential backoff delay with jitter
2275
- */
2276
- private calculateBackoff;
2277
- /**
2278
- * Execute request with retry logic (proxy mode) or single attempt (legacy mode)
2279
- */
2280
- private executeWithRetry;
2281
- /**
2282
- * Handle errors and create appropriate error responses
2283
- */
2284
- private handleError;
2285
- /**
2286
- * GET request
2287
- */
2288
- get<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
2289
- /**
2290
- * POST request
2291
- */
2292
- post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
2293
- /**
2294
- * PUT request
2295
- */
2296
- put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
2297
- /**
2298
- * DELETE request
2299
- */
2300
- delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
2301
- /**
2302
- * Update network parameter for subsequent requests
2303
- */
2304
- setNetwork(network: 'testnet' | 'mainnet'): void;
2305
- /**
2306
- * Get current network
2307
- */
2308
- getNetwork(): 'testnet' | 'mainnet';
2309
- }
2310
-
2311
- /**
2312
- * C-Address (Soroban Smart Account) response types
2313
- */
2314
- interface CAddressCreateResult {
2315
- cAddress: string;
2316
- txHash: string;
2317
- alreadyExisted: boolean;
2318
- explorerUrl: string;
2319
- }
2320
- interface CAddressLookupResult {
2321
- ownerGAddress: string;
2322
- cAddress: string | null;
2323
- hasAccount: boolean;
2324
- }
2325
- interface CAddressBalance {
2326
- asset: string;
2327
- balance: string;
2328
- symbol: string;
2329
- }
2330
- interface CAddressBalanceResult {
2331
- cAddress: string;
2332
- balances: CAddressBalance[];
2333
- }
2334
- interface CAddressBuildTransferResult {
2335
- unsignedXDR: string;
2336
- networkPassphrase: string;
2337
- }
2338
- interface CAddressSubmitResult {
2339
- txHash: string;
2340
- explorerUrl: string;
2341
- }
2342
- interface CAddressTransaction {
2343
- type: 'sent' | 'received';
2344
- asset: string;
2345
- amount: string;
2346
- counterparty: string;
2347
- txHash: string;
2348
- timestamp: string;
2349
- ledger: number;
2350
- }
2351
- interface CAddressHistoryResult {
2352
- cAddress: string;
2353
- transactions: CAddressTransaction[];
2354
- count: number;
2355
- }
2356
- interface CAddressHealthResult {
2357
- service: string;
2358
- relayerPublicKey: string;
2359
- factoryContractId: string;
2360
- isReady: boolean;
2361
- network: string;
2362
- }
2363
- /**
2364
- * Stellar C-Address Adapter — SDK for Soroban Smart Account operations
2365
- *
2366
- * Provides a clean interface for:
2367
- * - Creating C-addresses (smart accounts) from G-addresses
2368
- * - Looking up existing C-addresses by owner
2369
- * - Querying token balances (XLM, USDC, EURC)
2370
- * - Building bridge transfers (G→C)
2371
- * - Building smart account transfers (C→G, C→C)
2372
- * - Submitting user-signed transactions via fee-bump
2373
- * - Getting transaction history
2374
- *
2375
- * All transactions are gasless — the relayer covers fees via fee-bump.
2376
- *
2377
- * @example
2378
- * ```typescript
2379
- * import { SmoothSendSDK } from '@smoothsend/sdk';
2380
- *
2381
- * const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
2382
- *
2383
- * // Create a C-address for a G-address owner
2384
- * const { cAddress } = await sdk.stellar.cAddress.create('GABCD...');
2385
- *
2386
- * // Get balances
2387
- * const { balances } = await sdk.stellar.cAddress.getBalances(cAddress);
2388
- *
2389
- * // Build a bridge transfer (G→C), user signs, relayer fee-bumps
2390
- * const { unsignedXDR } = await sdk.stellar.cAddress.buildBridgeTransfer({
2391
- * from: 'GABCD...',
2392
- * destination: cAddress,
2393
- * asset: 'USDC',
2394
- * amount: '10.5',
2395
- * });
2396
- * // Sign with wallet (e.g., Freighter)
2397
- * const signedXDR = await wallet.signTransaction(unsignedXDR);
2398
- * // Submit — relayer wraps in fee-bump
2399
- * const { txHash } = await sdk.stellar.cAddress.submitTransfer(signedXDR);
2400
- * ```
2401
- */
2402
- declare class StellarCAddressAdapter {
2403
- private httpClient;
2404
- private basePath;
2405
- constructor(httpClient: HttpClient, network?: 'testnet' | 'mainnet');
2406
- /**
2407
- * Create a new C-address (Soroban Smart Account) for a G-address owner.
2408
- * If the owner already has a C-address, returns the existing one.
2409
- *
2410
- * The relayer pays all deployment fees — completely gasless for the user.
2411
- *
2412
- * @param ownerGAddress - The G-address that will control this smart account
2413
- * @returns The new C-address, tx hash, and whether it already existed
2414
- */
2415
- create(ownerGAddress: string): Promise<CAddressCreateResult>;
2416
- /**
2417
- * Look up the C-address for a given G-address owner.
2418
- * Returns null if no C-address exists for this owner.
2419
- *
2420
- * @param ownerGAddress - The G-address to look up
2421
- */
2422
- lookup(ownerGAddress: string): Promise<CAddressLookupResult>;
2423
- /**
2424
- * Get token balances for a C-address.
2425
- * Returns balances for XLM, USDC, and EURC.
2426
- *
2427
- * @param cAddress - The C-address to query
2428
- */
2429
- getBalances(cAddress: string): Promise<CAddressBalanceResult>;
2430
- /**
2431
- * Build a bridge transfer (G→C) using SAC.transfer.
2432
- * Returns unsigned XDR for the user to sign with their wallet.
2433
- * After signing, submit via submitTransfer().
2434
- *
2435
- * @param params.from - Sender G-address (signs the tx)
2436
- * @param params.destination - Recipient C-address (or G-address)
2437
- * @param params.asset - Asset to transfer: 'XLM', 'USDC', or 'EURC'
2438
- * @param params.amount - Human-readable amount (e.g., '10.5')
2439
- */
2440
- buildBridgeTransfer(params: {
2441
- from: string;
2442
- destination: string;
2443
- asset: string;
2444
- amount: string;
2445
- }): Promise<CAddressBuildTransferResult>;
2446
- /**
2447
- * Build a transfer from a C-address (SmartAccount.send).
2448
- * Returns unsigned XDR for the owner to sign.
2449
- * After signing, submit via submitTransfer().
2450
- *
2451
- * @param params.from - Owner G-address (signs auth)
2452
- * @param params.cAddress - Source C-address (holds the funds)
2453
- * @param params.destination - Recipient (G or C address)
2454
- * @param params.asset - Asset: 'XLM', 'USDC', or 'EURC'
2455
- * @param params.amount - Human-readable amount
2456
- */
2457
- buildTransfer(params: {
2458
- from: string;
2459
- cAddress: string;
2460
- destination: string;
2461
- asset: string;
2462
- amount: string;
2463
- }): Promise<CAddressBuildTransferResult>;
2464
- /**
2465
- * Submit a user-signed transaction.
2466
- * The relayer wraps it in a fee-bump transaction and submits to the network.
2467
- * The user pays zero fees — the relayer covers everything.
2468
- *
2469
- * @param signedXDR - The user-signed transaction XDR (base64)
2470
- */
2471
- submitTransfer(signedXDR: string): Promise<CAddressSubmitResult>;
2472
- /**
2473
- * Get transaction history for a C-address.
2474
- * Returns recent transfer events (sent/received) across all supported tokens.
2475
- *
2476
- * @param cAddress - The C-address to query
2477
- * @param limit - Maximum number of transactions to return (default: 20)
2478
- */
2479
- getHistory(cAddress: string, limit?: number): Promise<CAddressHistoryResult>;
2480
- /**
2481
- * Health check for the C-address bridge service.
2482
- */
2483
- health(): Promise<CAddressHealthResult>;
2484
- validateGAddress(address: string): void;
2485
- validateCAddress(address: string): void;
2486
- validateAddress(address: string): boolean;
2487
- }
2488
-
2489
- /**
2490
- * Stellar Adapter - Gasless transactions via Fee Bump
2491
- * Routes through proxy.smoothsend.xyz with API key authentication
2492
- * Supports XLM, USDC, EURC and other Stellar assets
2493
- */
2494
- declare class StellarAdapter implements IChainAdapter {
2495
- readonly chain: SupportedChain;
2496
- readonly config: ChainConfig;
2497
- /** C-Address (Soroban Smart Account) operations */
2498
- readonly cAddress: StellarCAddressAdapter;
2499
- private httpClient;
2500
- private network;
2501
- constructor(chain: SupportedChain, config: ChainConfig, apiKey: string, network?: 'testnet' | 'mainnet', includeOrigin?: boolean);
2502
- setNetwork(network: 'testnet' | 'mainnet'): void;
2503
- getNetwork(): 'testnet' | 'mainnet';
2504
- /**
2505
- * Stellar gasless: relayer pays fee. Returns 0 for user.
2506
- */
2507
- estimateFee(_request: TransferRequest): Promise<FeeEstimate>;
2508
- /**
2509
- * Submit signed XDR to relayer for Fee Bump wrapping
2510
- */
2511
- executeGaslessTransfer(signedData: SignedTransferData): Promise<TransferResult>;
2512
- getTransactionStatus(txHash: string): Promise<any>;
2513
- getHealth(): Promise<HealthResponse>;
2514
- validateAddress(address: string): boolean;
2515
- validateAmount(amount: string): boolean;
2516
- }
2517
-
2518
- /**
2519
- * SmoothSend SDK v2.0
2520
- *
2521
- * Multi-chain gasless transaction SDK for seamless dApp integration
2522
- *
2523
- * @remarks
2524
- * The SDK provides a simple interface for executing gasless token transfers
2525
- * across multiple blockchain networks. All requests route through the proxy
2526
- * worker at proxy.smoothsend.xyz with API key authentication.
2527
- *
2528
- * @packageDocumentation
2529
- *
2530
- * @example
2531
- * Aptos:
2532
- * ```typescript
2533
- * const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
2534
- * const result = await sdk.transfer({ from, to, token: 'USDC', amount: '1000000', chain: 'aptos-testnet' }, aptosWallet);
2535
- * ```
2536
- *
2537
- * @example
2538
- * Stellar (same API):
2539
- * ```typescript
2540
- * const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
2541
- * const result = await sdk.transfer({ from, to, token: 'XLM', amount: '100', chain: 'stellar-testnet' }, stellarWallet);
2542
- * ```
2543
- */
2544
-
2545
- /**
2546
- * SDK version
2547
- * @public
2548
- */
2549
- declare const VERSION = "2.2.1";
2550
-
2551
- export { APTOS_ERROR_CODES, AptosAdapter, AuthenticationError, CHAIN_ECOSYSTEM_MAP, HttpClient, NetworkError, RateLimitError, STELLAR_ERROR_CODES, ScriptComposerClient, SmoothSendError, SmoothSendSDK, SmoothSendSession, SmoothSendTransactionSubmitter, StellarAdapter, StellarCAddressAdapter, TrueGaslessClient, VERSION, ValidationError, createErrorFromResponse, createNetworkError, createScriptComposerClient, createSmoothSendSubmitter, createTrueGaslessClient, SmoothSendSDK as default, useSmoothSend };
2552
- export type { ApiResponse, AptosErrorCode, AptosTransferData, AptosWallet, AvalancheTransferData, BatchRelayTransferRequest, BatchTransferRequest, BuildTransferParams, BuildTransferResult, CAddressBalance, CAddressBalanceResult, CAddressBuildTransferResult, CAddressCreateResult, CAddressHealthResult, CAddressHistoryResult, CAddressLookupResult, CAddressSubmitResult, CAddressTransaction, ChainConfig, ChainEcosystem, ChainInfo, CreateSessionOptions, DomainSeparatorResponse, EVMTransferData, ErrorResponse, EstimateGasRequest, EventListener, ExecuteGaslessParams, ExecuteGaslessResult, FeeEstimate, FeeEstimateResult, GasEstimateResponse, HealthResponse, IChainAdapter, PermitData, PrepareSignatureRequest, PrepareSignatureResponse, RelayTransferRequest, RelayTransferResponse, ScriptComposerConfig, SessionInfo, SignatureData, SignedTransferData, SmoothSendConfig, SmoothSendTransactionSubmitterConfig, StellarWallet, SubmitResult, SubmitSignedTransactionParams, SubmitTransactionResult, SuccessResponse, SupportedChain, TokenBalance, TokenInfo, TransactionSubmitter, TransferData, TransferEvent, TransferQuote, TransferQuoteRequest, TransferQuoteResponse, TransferRequest, TransferResult, TransferStatusResponse, TrueGaslessConfig, UsageMetadata, UseSmoothSendResult };
1
+ export { S as SmoothSendSDK, S as default } from './chunks/shared-RVkwmkG7.js';
2
+ export { AptosAdapter, BuildTransferParams, BuildTransferResult, CreateSessionOptions, ExecuteGaslessParams, ExecuteGaslessResult, FeeEstimateResult, ScriptComposerClient, ScriptComposerConfig, SessionInfo, SmoothSendSession, SmoothSendTransactionSubmitter, SmoothSendTransactionSubmitterConfig, SubmitResult, SubmitSignedTransactionParams, SubmitTransactionResult, TransactionSubmitter, TrueGaslessClient, TrueGaslessConfig, UseSmoothSendResult, createScriptComposerClient, createSmoothSendSubmitter, createTrueGaslessClient, useSmoothSend } from './aptos/index.js';
3
+ export { AvaxAaPublicDefaults, AvaxSponsorshipMode, AvaxSubmitter, ENTRY_POINT_V07_ADDRESS, GasEstimateAvax, PaymasterSignRequestAvax, PaymasterSignResponseAvax, SIMPLE_ACCOUNT_FACTORY_ABI, SmoothSendAvaxContextValue, SmoothSendAvaxProvider, SmoothSendAvaxSubmitter, SmoothSendAvaxSubmitterConfig, SponsoredUserOpDraftAvax, SubmitSponsoredAvaxUserOpOptions, UseSmoothSendAvaxParams, UserOperationAvax, UserOperationReceiptAvax, avaxExecuteAbi, createSmoothSendAvaxSubmitter, encodeAvaxExecuteCalldata, encodeCreateAccountFactoryData, fetchAvaxAaPublicDefaults, hashUserOperationAvax, predictSimpleAccountAddress, readAvaxSenderNonce, useSmoothSendAvax, useSmoothSendAvaxContext, userOperationAvaxToViem } from './avax/index.js';
4
+ export { CAddressBalance, CAddressBalanceResult, CAddressBuildTransferResult, CAddressCreateResult, CAddressHealthResult, CAddressHistoryResult, CAddressLookupResult, CAddressSubmitResult, CAddressTransaction, StellarAdapter, StellarCAddressAdapter } from './stellar/index.js';
5
+ export { w as APTOS_ERROR_CODES, z as ApiResponse, x as AptosErrorCode, j as AptosTransferData, J as AptosWallet, Q as AuthenticationError, A as AvalancheTransferData, p as BatchRelayTransferRequest, B as BatchTransferRequest, a as CHAIN_ECOSYSTEM_MAP, d as ChainConfig, C as ChainEcosystem, c as ChainInfo, D as DomainSeparatorResponse, i as EVMTransferData, E as ErrorResponse, q as EstimateGasRequest, M as EventListener, F as FeeEstimate, G as GasEstimateResponse, u as HealthResponse, H as HttpClient, N as IChainAdapter, Y as NetworkError, s as PermitData, P as PrepareSignatureRequest, t as PrepareSignatureResponse, W as RateLimitError, o as RelayTransferRequest, R as RelayTransferResponse, y as STELLAR_ERROR_CODES, k as SignatureData, l as SignedTransferData, I as SmoothSendConfig, O as SmoothSendError, K as StellarWallet, b as SuccessResponse, S as SupportedChain, m as TokenBalance, T as TokenInfo, r as TransferData, L as TransferEvent, g as TransferQuote, n as TransferQuoteRequest, f as TransferQuoteResponse, e as TransferRequest, h as TransferResult, v as TransferStatusResponse, U as UsageMetadata, V as VERSION, X as ValidationError, Z as createErrorFromResponse, _ as createNetworkError } from './chunks/shared-Cn4duBJT.js';
6
+ import '@aptos-labs/ts-sdk';
7
+ import 'viem';
8
+ import 'viem/account-abstraction';
9
+ import 'react/jsx-runtime';
10
+ import 'react';
11
+ import 'axios';