@smoothsend/sdk 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,429 +1,349 @@
1
- # SmoothSend SDK
2
-
3
- Multi-chain gasless transaction SDK. Enable gas-free transactions with just 3 lines of code. Supports **Aptos** and **Stellar**.
4
-
5
- [![npm version](https://badge.fury.io/js/@smoothsend/sdk.svg)](https://www.npmjs.com/package/@smoothsend/sdk)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
-
9
- ## 🚀 Features
10
-
11
- - **Gasless Transactions**: Users don't need APT or XLM for gas fees
12
- - **Multi-Chain**: Aptos + Stellar (same 3-line API)
13
- - **3-Line Integration**: Works with Aptos Wallet Adapter and Stellar wallets (Freighter, etc.)
14
- - **Type-Safe**: Full TypeScript support with comprehensive type definitions
15
- - **Testnet & Mainnet**: Supports both networks on each chain
16
- - **Fee-in-Token**: On Aptos mainnet, tiny fee deducted from token (not APT)
17
-
18
- ## 📦 Installation
19
-
20
- ```bash
21
- npm install @smoothsend/sdk
22
- ```
23
-
24
- ## ⚡ Quick Start - Wallet Adapter (EASIEST - All Transactions Gasless)
25
-
26
- The simplest integration — pass `transactionSubmitter` to your wallet provider and **every transaction becomes gasless automatically**. Ideal when you want to sponsor all functions.
27
-
28
- ```typescript
29
- import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
30
- import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react';
31
- import { Network } from '@aptos-labs/ts-sdk';
32
-
33
- // 1. Create the transaction submitter (one line!)
34
- const transactionSubmitter = new SmoothSendTransactionSubmitter({
35
- apiKey: 'pk_nogas_your_api_key_here',
36
- network: 'testnet'
37
- });
38
-
39
- // 2. Add to your wallet provider
40
- function App() {
41
- return (
42
- <AptosWalletAdapterProvider
43
- dappConfig={{
44
- network: Network.TESTNET,
45
- transactionSubmitter: transactionSubmitter // <-- That's it!
46
- }}
47
- >
48
- <YourApp />
49
- </AptosWalletAdapterProvider>
50
- );
51
- }
52
-
53
- // 3. Use normal wallet functions - they're now gasless!
54
- function TransferButton() {
55
- const { signAndSubmitTransaction } = useWallet();
56
-
57
- const handleTransfer = async () => {
58
- // This is now gasless! No code changes needed!
59
- const result = await signAndSubmitTransaction({
60
- data: {
61
- function: "0x1::coin::transfer",
62
- typeArguments: ["0x1::aptos_coin::AptosCoin"],
63
- functionArguments: [recipientAddress, amount],
64
- }
65
- });
66
- console.log('Gasless transaction:', result.hash);
67
- };
68
-
69
- return <button onClick={handleTransfer}>Send (Gasless!)</button>;
70
- }
71
- ```
72
-
73
- ---
74
-
75
- ## 🎯 useSmoothSend Hook (Per-Function Routing)
76
-
77
- Use `useSmoothSend` when you want **some functions gasless and others not** — for example, free to create but user pays to delete. The hook automatically routes each transaction based on your project's sponsored-functions allowlist configured in the dashboard.
78
-
79
- ```typescript
80
- import { useSmoothSend, SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
81
-
82
- // Create once at module scope (not inside the component)
83
- const submitter = new SmoothSendTransactionSubmitter({
84
- apiKey: process.env.NEXT_PUBLIC_SMOOTHSEND_API_KEY!,
85
- network: 'testnet',
86
- });
87
-
88
- function MyComponent() {
89
- // Drop-in replacement for useWallet().signAndSubmitTransaction
90
- const { signAndSubmitTransaction } = useSmoothSend(submitter);
91
-
92
- const handleAction = async () => {
93
- // Automatically routed:
94
- // function in allowlist → fee-payer gasless (user pays 0 gas)
95
- // function not in list → walletSignAndSubmit fallback (user pays gas)
96
- await signAndSubmitTransaction({
97
- data: {
98
- function: '0xABC::mymodule::my_function',
99
- functionArguments: [arg1, arg2],
100
- }
101
- });
102
- };
103
- }
104
- ```
105
-
106
- **Requirements for `useSmoothSend`:**
107
- - `react >= 17`
108
- - `@aptos-labs/wallet-adapter-react >= 8`
109
- - `@aptos-labs/ts-sdk >= 5.0.0` ← required for `withFeePayer: true` support
110
-
111
- **Do NOT use `transactionSubmitter` in `AptosWalletAdapterProvider`** when using `useSmoothSend` — the hook handles all routing directly.
112
-
113
- ### When to use which
114
-
115
- | Want to... | Use |
116
- |---|---|
117
- | Make ALL transactions gasless, zero config | `transactionSubmitter` in `AptosWalletAdapterProvider` |
118
- | Sponsor only specific functions (allowlist) | `useSmoothSend(submitter)` hook |
119
- | Mainnet free tier — deduct fee from token | `ScriptComposerClient` |
120
-
121
- ---
122
-
123
- ## 💰 Script Composer - Fee-in-Token Transfers
124
-
125
- For **mainnet with free tier**, use Script Composer to deduct fees from the token being transferred:
126
-
127
- ```typescript
128
- import { ScriptComposerClient } from '@smoothsend/sdk';
129
-
130
- // Create client for mainnet
131
- const client = new ScriptComposerClient({
132
- apiKey: 'pk_nogas_your_api_key',
133
- network: 'mainnet'
134
- });
135
-
136
- // Step 1: Build transfer (fee calculated automatically)
137
- const { transactionBytes, fee, totalAmount } = await client.buildTransfer({
138
- sender: wallet.address,
139
- recipient: '0x123...',
140
- amount: '1000000', // 1 USDC
141
- assetType: '0xf22bede...::usdc::USDC',
142
- decimals: 6,
143
- symbol: 'USDC'
144
- });
145
-
146
- console.log(`Sending 1 USDC, fee: ${fee} (deducted from token)`);
147
-
148
- // Step 2: Sign with wallet
149
- const signedTx = await wallet.signTransaction(transactionBytes);
150
-
151
- // Step 3: Submit
152
- const result = await client.submitSignedTransaction({
153
- transactionBytes: signedTx.transactionBytes,
154
- authenticatorBytes: signedTx.authenticatorBytes
155
- });
156
-
157
- console.log('Transaction:', result.txHash);
158
- ```
159
-
160
- ### When to Use Each Method
161
-
162
- | Scenario | Method | Why |
163
- |----------|--------|-----|
164
- | **Testnet (any tier)** | TransactionSubmitter | Always free on testnet |
165
- | **Mainnet + Free tier** | ScriptComposerClient | Fee deducted from token ($0.01/tx) |
166
- | **Mainnet + Paid tier** | TransactionSubmitter | Zero fees included in subscription |
167
- | **Swaps, NFTs, contracts** | TransactionSubmitter | Script Composer only supports transfers |
168
- | **Token transfers (monetize)** | ScriptComposerClient | Pass fee to users |
169
-
170
- ### Script Composer Methods
171
-
172
- ```typescript
173
- // Estimate fee without building transaction
174
- const estimate = await client.estimateFee({
175
- sender: '0x...',
176
- recipient: '0x...',
177
- amount: '1000000',
178
- assetType: USDC_ADDRESS,
179
- decimals: 6,
180
- symbol: 'USDC'
181
- });
182
-
183
- console.log('Fee:', estimate.estimation.formatted.fee);
184
- console.log('Total:', estimate.estimation.formatted.totalAmount);
185
-
186
- // Or use the convenience method for complete flow
187
- const result = await client.transfer(transferParams, wallet);
188
- ```
189
-
190
- ---
191
-
192
- ## ⚠️ Important Security Update
193
-
194
- **For Aptos transactions**, the SDK uses a **secure serialized transaction approach** that requires proper wallet integration using the Aptos Wallet Standard.
195
-
196
- See the [Wallet Adapter Integration](#-quick-start---wallet-adapter-easiest---3-lines) section for the recommended implementation.
197
-
198
- ## 🔑 Authentication
199
-
200
- SmoothSend uses API keys for authentication. There are two types of keys:
201
-
202
- ### Public Keys (`pk_nogas_*`)
203
- - **Safe for frontend applications** - Can be embedded in client-side code
204
- - **CORS-protected** - Only work from configured domains
205
- - **Use in**: React apps, Vue apps, browser extensions, mobile apps
206
-
207
- ### Secret Keys (`sk_nogas_*`)
208
- - **Server-side only** - Must never be exposed in client-side code
209
- - **No CORS restrictions** - Work from any server environment
210
- - **Use in**: Node.js backends, serverless functions, API servers
211
-
212
- ### Getting Your API Keys
213
-
214
- 1. Sign up at [dashboard.smoothsend.xyz](https://dashboard.smoothsend.xyz)
215
- 2. Create a project
216
- 3. Generate an API key pair - you'll receive both a public and secret key
217
- 4. Configure CORS origins for your public key
218
-
219
- ### Security Best Practices
220
-
221
- ⚠️ **Never commit secret keys to version control**
222
- ⚠️ **Never expose secret keys in client-side code**
223
- ✅ **Use public keys for frontend applications**
224
- ✅ **Use secret keys for backend services**
225
- ✅ **Configure CORS origins for production domains**
226
-
227
- ## 🏁 Classic SDK Usage
228
-
229
- If you prefer more control over the transaction flow, you can use the classic SDK approach:
230
-
231
- ### Frontend Example (Public Key)
232
-
233
- ```typescript
234
- import { SmoothSendSDK } from '@smoothsend/sdk';
235
-
236
- // Initialize with public key (safe for frontend)
237
- const smoothSend = new SmoothSendSDK({
238
- apiKey: 'pk_nogas_your_public_key_here',
239
- network: 'testnet',
240
- timeout: 30000,
241
- retries: 3
242
- });
243
-
244
- // Create a transfer request
245
- const transferRequest = {
246
- from: '0x742d35cc6634c0532925a3b8d2d2d2d2d2d2d2d2',
247
- to: '0x742d35cc6634c0532925a3b8d2d2d2d2d2d2d2d3',
248
- token: 'USDC',
249
- amount: '1000000', // 1 USDC (6 decimals)
250
- chain: 'aptos-testnet' as const
251
- };
252
-
253
- // Execute transfer (with wallet signer)
254
- try {
255
- const result = await smoothSend.transfer(transferRequest, walletSigner);
256
- console.log('Transfer successful:', result.txHash);
257
- } catch (error) {
258
- console.error('Transfer failed:', error.message);
259
- }
260
- ```
261
-
262
- ### Backend Example (Secret Key)
263
-
264
- ```typescript
265
- import { SmoothSendSDK } from '@smoothsend/sdk';
266
-
267
- // Initialize with secret key (server-side only)
268
- const smoothSend = new SmoothSendSDK({
269
- apiKey: 'sk_nogas_your_secret_key_here',
270
- network: 'mainnet',
271
- timeout: 30000,
272
- retries: 3
273
- });
274
-
275
- // Execute Aptos transfer from backend
276
- const result = await smoothSend.executeGaslessTransfer({
277
- transactionBytes: signedTx.transactionBytes,
278
- authenticatorBytes: signedTx.authenticatorBytes,
279
- chain: 'aptos-mainnet',
280
- network: 'mainnet'
281
- });
282
-
283
- // Or Stellar - submit signed XDR
284
- const stellarResult = await smoothSend.submitStellarTransaction(signedXdr);
285
-
286
- console.log('Transfer successful:', result.txHash);
287
- ```
288
-
289
- ## ⭐ Stellar - Gasless XLM & USDC
290
-
291
- Same 3-line API for Stellar. Use with Freighter, Stellar Wallets Kit, or any Stellar-compatible wallet.
292
-
293
- ```typescript
294
- import { SmoothSendSDK } from '@smoothsend/sdk';
295
-
296
- const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
297
-
298
- // Option 1: Full transfer (build + sign + submit)
299
- const result = await sdk.transfer(
300
- { from: 'G...', to: 'G...', amount: '100', token: 'XLM', chain: 'stellar-testnet' },
301
- stellarWallet
302
- );
303
-
304
- // Option 2: Submit pre-signed XDR
305
- const signedXdr = await wallet.signTransaction(tx);
306
- const result = await sdk.submitStellarTransaction(signedXdr);
307
- ```
308
-
309
- **Stellar wallet interface:**
310
- ```typescript
311
- const stellarWallet = {
312
- buildTransaction: (params) => buildPaymentTransaction(params.from, params.to, params.amount, params.token),
313
- signTransaction: (tx) => walletKit.signTransaction(tx.toXDR()).then(r => r.signedTxXdr),
314
- };
315
- ```
316
-
317
- ## 🔧 Supported Networks
318
-
319
- | Network | Status | Features |
320
- |---------|--------|----------|
321
- | Aptos Testnet | ✅ Active | Gasless transactions, Ed25519 signatures |
322
- | Aptos Mainnet | ✅ Active | Gasless transactions, Fee-in-token option |
323
- | Stellar Testnet | ✅ Active | Gasless XLM, USDC, EURC via Fee Bump |
324
- | Stellar Mainnet | ✅ Active | Gasless XLM, USDC, EURC via Fee Bump |
325
-
326
- ## 📚 API Reference
327
-
328
- ### SmoothSendTransactionSubmitter
329
-
330
- The recommended way to integrate - works with Aptos Wallet Adapter.
331
-
332
- ```typescript
333
- import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
334
-
335
- const submitter = new SmoothSendTransactionSubmitter({
336
- apiKey: 'pk_nogas_your_api_key',
337
- network: 'testnet' // or 'mainnet'
338
- });
339
-
340
- // Pass to AptosWalletAdapterProvider
341
- <AptosWalletAdapterProvider
342
- dappConfig={{
343
- network: Network.TESTNET,
344
- transactionSubmitter: submitter
345
- }}
346
- >
347
- ```
348
-
349
- ### ScriptComposerClient
350
-
351
- For mainnet transfers with fee-in-token (fee deducted from transferred amount).
352
-
353
- ```typescript
354
- import { ScriptComposerClient } from '@smoothsend/sdk';
355
-
356
- const client = new ScriptComposerClient({
357
- apiKey: 'pk_nogas_your_api_key',
358
- network: 'mainnet'
359
- });
360
-
361
- // Build transfer
362
- const { transactionBytes, fee } = await client.buildTransfer({
363
- sender: '0x...',
364
- recipient: '0x...',
365
- amount: '1000000',
366
- assetType: USDC_ADDRESS,
367
- decimals: 6,
368
- symbol: 'USDC'
369
- });
370
-
371
- // Estimate fee
372
- const estimate = await client.estimateFee(transferParams);
373
-
374
- // Submit signed transaction
375
- const result = await client.submitSignedTransaction({
376
- transactionBytes,
377
- authenticatorBytes
378
- });
379
- ```
380
-
381
- ### SmoothSendSDK (Classic)
382
-
383
- Direct SDK usage for more control. Works for both Aptos and Stellar.
384
-
385
- ```typescript
386
- import { SmoothSendSDK } from '@smoothsend/sdk';
387
-
388
- const smoothSend = new SmoothSendSDK({
389
- apiKey: 'pk_nogas_your_api_key',
390
- network: 'testnet',
391
- timeout: 30000,
392
- retries: 3
393
- });
394
-
395
- // Aptos - execute gasless transfer
396
- const result = await smoothSend.executeGaslessTransfer({
397
- transactionBytes: signedTx.transactionBytes,
398
- authenticatorBytes: signedTx.authenticatorBytes,
399
- chain: 'aptos-testnet',
400
- network: 'testnet'
401
- });
402
-
403
- // Stellar - submit signed XDR
404
- const stellarResult = await smoothSend.submitStellarTransaction(signedXdr);
405
- ```
406
-
407
- ## 🔐 Security
408
-
409
- - All transactions require user signature approval
410
- - Private keys never leave the client
411
- - Rate limiting and validation on relayer endpoints
412
- - Comprehensive input validation
413
- - Public keys are CORS-protected (safe for frontend)
414
- - Secret keys for backend only
415
-
416
- ## 🔗 Links
417
-
418
- - **Dashboard**: [dashboard.smoothsend.xyz](https://dashboard.smoothsend.xyz)
419
- - **Documentation**: [docs.smoothsend.xyz](https://docs.smoothsend.xyz)
420
- - **GitHub**: [github.com/smoothsend](https://github.com/smoothsend)
421
-
422
- ## 📄 License
423
-
424
- MIT
425
-
426
- ---
427
-
428
- Built with ❤️ by the SmoothSend team
429
-
1
+ # SmoothSend SDK
2
+
3
+ Multi-chain gasless transaction SDK. Enable gas-free transactions with just 3 lines of code. Supports **Aptos** and **Stellar**.
4
+
5
+ [![npm version](https://badge.fury.io/js/@smoothsend/sdk.svg)](https://www.npmjs.com/package/@smoothsend/sdk)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ## Features
10
+
11
+ - **Gasless Transactions**: Users don't need APT or XLM for gas fees
12
+ - **Multi-Chain**: Aptos + Stellar (same 3-line API)
13
+ - **3-Line Integration**: Works with Aptos Wallet Adapter and Stellar wallets (Freighter, etc.)
14
+ - **Type-Safe**: Full TypeScript support with comprehensive type definitions
15
+ - **Testnet & Mainnet**: Supports both networks on each chain
16
+ - **Fee-in-Token**: On Aptos mainnet, tiny fee deducted from token (not APT)
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @smoothsend/sdk
22
+ ```
23
+
24
+ ---
25
+
26
+ ## Quick Start
27
+
28
+ ### Wallet Adapter (EASIEST — All Transactions Gasless)
29
+
30
+ The simplest integration — pass `transactionSubmitter` to your wallet provider and **every transaction becomes gasless automatically**. Ideal when you want to sponsor all functions.
31
+
32
+ ```typescript
33
+ import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
34
+ import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react';
35
+ import { Network } from '@aptos-labs/ts-sdk';
36
+
37
+ // 1. Create the transaction submitter (one line!)
38
+ const transactionSubmitter = new SmoothSendTransactionSubmitter({
39
+ apiKey: 'pk_nogas_your_api_key_here',
40
+ network: 'testnet'
41
+ });
42
+
43
+ // 2. Add to your wallet provider
44
+ function App() {
45
+ return (
46
+ <AptosWalletAdapterProvider
47
+ dappConfig={{
48
+ network: Network.TESTNET,
49
+ transactionSubmitter: transactionSubmitter // <-- That's it!
50
+ }}
51
+ >
52
+ <YourApp />
53
+ </AptosWalletAdapterProvider>
54
+ );
55
+ }
56
+
57
+ // 3. Use normal wallet functions - they're now gasless!
58
+ function TransferButton() {
59
+ const { signAndSubmitTransaction } = useWallet();
60
+
61
+ const handleTransfer = async () => {
62
+ // This is now gasless! No code changes needed!
63
+ const result = await signAndSubmitTransaction({
64
+ data: {
65
+ function: "0x1::coin::transfer",
66
+ typeArguments: ["0x1::aptos_coin::AptosCoin"],
67
+ functionArguments: [recipientAddress, amount],
68
+ }
69
+ });
70
+ console.log('Gasless transaction:', result.hash);
71
+ };
72
+
73
+ return <button onClick={handleTransfer}>Send (Gasless!)</button>;
74
+ }
75
+ ```
76
+
77
+ ---
78
+
79
+ ### useSmoothSend Hook (Per-Function Routing)
80
+
81
+ Use `useSmoothSend` when you want **some functions gasless and others not** — for example, free to create but user pays to delete. The hook automatically routes each transaction based on your project's sponsored-functions allowlist configured in the dashboard.
82
+
83
+ ```typescript
84
+ import { useSmoothSend, SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
85
+
86
+ // Create once at module scope (not inside the component)
87
+ const submitter = new SmoothSendTransactionSubmitter({
88
+ apiKey: process.env.NEXT_PUBLIC_SMOOTHSEND_API_KEY!,
89
+ network: 'testnet',
90
+ });
91
+
92
+ function MyComponent() {
93
+ // Drop-in replacement for useWallet().signAndSubmitTransaction
94
+ const { signAndSubmitTransaction } = useSmoothSend(submitter);
95
+
96
+ const handleAction = async () => {
97
+ // Automatically routed:
98
+ // function in allowlist → fee-payer gasless (user pays 0 gas)
99
+ // function not in list → walletSignAndSubmit fallback (user pays gas)
100
+ await signAndSubmitTransaction({
101
+ data: {
102
+ function: '0xABC::mymodule::my_function',
103
+ functionArguments: [arg1, arg2],
104
+ }
105
+ });
106
+ };
107
+ }
108
+ ```
109
+
110
+ > **Note:** Do NOT use `transactionSubmitter` in `AptosWalletAdapterProvider` when using `useSmoothSend` — the hook handles all routing directly.
111
+ >
112
+ > **Requirements:** `react >= 17`, `@aptos-labs/wallet-adapter-react >= 8`, `@aptos-labs/ts-sdk >= 5.0.0`
113
+
114
+ ---
115
+
116
+ ### True Gasless (Backend)
117
+
118
+ For Node.js backends running 100% sponsored transactions for arbitrary generic payloads using a secret key.
119
+
120
+ ```typescript
121
+ import { TrueGaslessClient } from '@smoothsend/sdk';
122
+ import { Account, Ed25519PrivateKey } from '@aptos-labs/ts-sdk';
123
+
124
+ // 1. Instantiate the backend account (keep your private key safe!)
125
+ const backendWallet = Account.fromPrivateKey({
126
+ privateKey: new Ed25519PrivateKey(process.env.APTOS_PRIVATE_KEY!)
127
+ });
128
+
129
+ // 2. Create client using your secret key
130
+ const client = new TrueGaslessClient({
131
+ apiKey: process.env.SMOOTHSEND_SECRET_KEY!, // sk_nogas_*
132
+ network: 'mainnet'
133
+ });
134
+
135
+ // 3. Build & execute your Move transaction payload
136
+ const result = await client.execute({
137
+ senderAccount: backendWallet,
138
+ payload: {
139
+ function: "0x12b...::nft::mint_to",
140
+ functionArguments: [recipientAddress, "1"]
141
+ }
142
+ });
143
+
144
+ console.log('Gasless transaction executed:', result.txHash);
145
+ ```
146
+
147
+ ---
148
+
149
+ ### Script Composer — Fee-in-Token Transfers
150
+
151
+ For mainnet with the free tier, Script Composer deducts fees from the token being transferred rather than requiring APT.
152
+
153
+ ```typescript
154
+ import { ScriptComposerClient } from '@smoothsend/sdk';
155
+
156
+ const client = new ScriptComposerClient({
157
+ apiKey: 'pk_nogas_your_api_key',
158
+ network: 'mainnet'
159
+ });
160
+
161
+ // Step 1: Build transfer (fee calculated automatically)
162
+ const { transactionBytes, fee, totalAmount } = await client.buildTransfer({
163
+ sender: wallet.address,
164
+ recipient: '0x123...',
165
+ amount: '1000000', // 1 USDC
166
+ assetType: '0xf22bede...::usdc::USDC',
167
+ decimals: 6,
168
+ symbol: 'USDC'
169
+ });
170
+
171
+ console.log(`Sending 1 USDC, fee: ${fee} (deducted from token)`);
172
+
173
+ // Step 2: Sign with wallet
174
+ const signedTx = await wallet.signTransaction(transactionBytes);
175
+
176
+ // Step 3: Submit
177
+ const result = await client.submitSignedTransaction({
178
+ transactionBytes: signedTx.transactionBytes,
179
+ authenticatorBytes: signedTx.authenticatorBytes
180
+ });
181
+
182
+ console.log('Transaction:', result.txHash);
183
+ ```
184
+
185
+ Additional `ScriptComposerClient` methods:
186
+
187
+ ```typescript
188
+ // Estimate fee without building a transaction
189
+ const estimate = await client.estimateFee({
190
+ sender: '0x...',
191
+ recipient: '0x...',
192
+ amount: '1000000',
193
+ assetType: USDC_ADDRESS,
194
+ decimals: 6,
195
+ symbol: 'USDC'
196
+ });
197
+
198
+ console.log('Fee:', estimate.estimation.formatted.fee);
199
+ console.log('Total:', estimate.estimation.formatted.totalAmount);
200
+
201
+ // Or use the convenience method for the complete flow
202
+ const result = await client.transfer(transferParams, wallet);
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Choosing an Integration
208
+
209
+ | Scenario | Method | Notes |
210
+ |---|---|---|
211
+ | Make ALL transactions gasless, zero config | `transactionSubmitter` in `AptosWalletAdapterProvider` | Simplest setup |
212
+ | Sponsor only specific functions (allowlist) | `useSmoothSend(submitter)` hook | Per-function routing |
213
+ | Testnet (any tier) | `TransactionSubmitter` | Always free on testnet |
214
+ | Mainnet + Free tier | `ScriptComposerClient` | Fee deducted from token (~$0.01/tx) |
215
+ | Mainnet + Paid tier | `TransactionSubmitter` | Zero fees included in subscription |
216
+ | Swaps, NFTs, contracts | `TransactionSubmitter` | Script Composer supports transfers only |
217
+ | Token transfers you want to monetize | `ScriptComposerClient` | Pass the fee cost to your users |
218
+ | Backend / server-side transactions | `TrueGaslessClient` | Requires secret key (`sk_nogas_*`) |
219
+
220
+ ---
221
+
222
+ ## Stellar — Gasless XLM & USDC
223
+
224
+ Same 3-line API for Stellar. Works with Freighter, Stellar Wallets Kit, or any Stellar-compatible wallet.
225
+
226
+ ```typescript
227
+ import { SmoothSendSDK } from '@smoothsend/sdk';
228
+
229
+ const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
230
+
231
+ // Option 1: Full transfer (build + sign + submit)
232
+ const result = await sdk.transfer(
233
+ { from: 'G...', to: 'G...', amount: '100', token: 'XLM', chain: 'stellar-testnet' },
234
+ stellarWallet
235
+ );
236
+
237
+ // Option 2: Submit pre-signed XDR
238
+ const signedXdr = await wallet.signTransaction(tx);
239
+ const result = await sdk.submitStellarTransaction(signedXdr);
240
+ ```
241
+
242
+ **Stellar wallet interface:**
243
+
244
+ ```typescript
245
+ const stellarWallet = {
246
+ buildTransaction: (params) => buildPaymentTransaction(params.from, params.to, params.amount, params.token),
247
+ signTransaction: (tx) => walletKit.signTransaction(tx.toXDR()).then(r => r.signedTxXdr),
248
+ };
249
+ ```
250
+
251
+ ---
252
+
253
+ ## Supported Networks
254
+
255
+ | Network | Status | Features |
256
+ |---|---|---|
257
+ | Aptos Testnet | ✅ Active | Gasless transactions, Ed25519 signatures |
258
+ | Aptos Mainnet | ✅ Active | Gasless transactions, fee-in-token option |
259
+ | Stellar Testnet | ✅ Active | Gasless XLM, USDC, EURC via Fee Bump |
260
+ | Stellar Mainnet | ✅ Active | Gasless XLM, USDC, EURC via Fee Bump |
261
+
262
+ ---
263
+
264
+ ## Authentication
265
+
266
+ SmoothSend uses two types of API keys:
267
+
268
+ ### Public Keys (`pk_nogas_*`)
269
+
270
+ - Safe for frontend applications — can be embedded in client-side code
271
+ - CORS-protected — only work from configured domains
272
+ - Use in: React apps, Vue apps, browser extensions, mobile apps
273
+
274
+ ### Secret Keys (`sk_nogas_*`)
275
+
276
+ - Server-side only — must never be exposed in client-side code
277
+ - No CORS restrictions — work from any server environment
278
+ - Use in: Node.js backends, serverless functions, API servers
279
+
280
+ ### Getting Your API Keys
281
+
282
+ 1. Sign up at [dashboard.smoothsend.xyz](https://dashboard.smoothsend.xyz)
283
+ 2. Create a project
284
+ 3. Generate an API key pair — you'll receive both a public and secret key
285
+ 4. Configure CORS origins for your public key
286
+
287
+ ### Security Best Practices
288
+
289
+ - ⚠️ Never commit secret keys to version control
290
+ - ⚠️ Never expose secret keys in client-side code
291
+ - ✅ Use public keys for frontend applications
292
+ - ✅ Use secret keys for backend services only
293
+ - ✅ Configure CORS origins for all production domains
294
+ - ✅ All transactions require user signature approval — private keys never leave the client
295
+ - ✅ Rate limiting and input validation are enforced on all relayer endpoints
296
+
297
+ ---
298
+
299
+ ## MCP Server
300
+
301
+ SmoothSend ships an [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that lets AI assistants — Claude, Cursor, and others — help you integrate gasless transactions directly from your editor or chat interface.
302
+
303
+ ```bash
304
+ npm install -g @smoothsend/mcp
305
+ ```
306
+
307
+ Once installed, add it to your MCP client config:
308
+
309
+ **Claude Desktop** (`claude_desktop_config.json`):
310
+
311
+ ```json
312
+ {
313
+ "mcpServers": {
314
+ "smoothsend": {
315
+ "command": "smoothsend-mcp"
316
+ }
317
+ }
318
+ }
319
+ ```
320
+
321
+ **Cursor** (`.cursor/mcp.json`):
322
+
323
+ ```json
324
+ {
325
+ "mcpServers": {
326
+ "smoothsend": {
327
+ "command": "smoothsend-mcp"
328
+ }
329
+ }
330
+ }
331
+ ```
332
+
333
+ Your AI assistant will then have full context on the SmoothSend API, client types, and integration patterns — making it faster to scaffold and debug gasless transaction flows.
334
+
335
+ ---
336
+
337
+ ## Links
338
+
339
+ - **Dashboard**: [dashboard.smoothsend.xyz](https://dashboard.smoothsend.xyz)
340
+ - **Documentation**: [docs.smoothsend.xyz](https://docs.smoothsend.xyz)
341
+ - **GitHub**: [github.com/smoothsend](https://github.com/smoothsend)
342
+
343
+ ## License
344
+
345
+ MIT
346
+
347
+ ---
348
+
349
+ Built with ❤️ by the SmoothSend team