@smoothsend/sdk 2.3.8 → 2.3.9
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/LICENSE +22 -22
- package/README.md +408 -349
- package/dist/aptos/index.cjs +2 -2
- package/dist/aptos/index.d.ts +5 -5
- package/dist/aptos/index.js +2 -2
- package/dist/aptos-privy/types.d.ts +2 -2
- package/dist/aptos-privy/types.d.ts.map +1 -1
- package/dist/avax/index.d.ts +1 -1
- package/dist/chunks/{shared-vFCAUg0m.d.ts → shared-CRch0act.d.ts} +3 -3
- package/dist/chunks/{shared-DMOh_aLU.d.ts → shared-D12TV8pI.d.ts} +1 -1
- package/dist/chunks/{shared-W7k9S_GY.d.ts → shared-DfBF-Qwo.d.ts} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/session/SmoothSendSession.d.ts +1 -1
- package/dist/stellar/index.d.ts +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/wallet-adapter/useSmoothSend.d.ts +1 -1
- package/package.json +120 -120
- package/dist/adapters/evm.d.ts +0 -39
- package/dist/adapters/evm.d.ts.map +0 -1
- package/dist/config/chains.d.ts +0 -7
- package/dist/config/chains.d.ts.map +0 -1
- package/dist/index.esm.js +0 -3319
- package/dist/index.esm.js.map +0 -1
- package/dist/services/chainConfigService.d.ts +0 -49
- package/dist/services/chainConfigService.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,349 +1,408 @@
|
|
|
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
|
-
[](https://www.typescriptlang.org/)
|
|
7
|
-
[](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**:
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
1
|
+
# SmoothSend SDK
|
|
2
|
+
|
|
3
|
+
Multi-chain gasless transaction SDK. Enable gas-free transactions with just 3 lines of code. Supports **Aptos**, **Avalanche** (C-Chain mainnet + Fuji testnet, ERC-4337), and **Stellar** (testnet only, beta).
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@smoothsend/sdk)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Gasless Transactions**: Users don't need APT, AVAX, or XLM for gas fees
|
|
12
|
+
- **Multi-Chain**: Aptos + Avalanche (ERC-4337) + Stellar (same 3-line API)
|
|
13
|
+
- **3-Line Integration**: Works with Aptos Wallet Adapter, wagmi/Privy (Avalanche), and Stellar wallets (Freighter, etc.)
|
|
14
|
+
- **Type-Safe**: Full TypeScript support with comprehensive type definitions
|
|
15
|
+
- **Testnet & Mainnet**: Aptos and Avalanche support both networks; Stellar is testnet only for now
|
|
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
|
+
// Native APT uses aptos_account::transfer (no type argument needed):
|
|
64
|
+
const result = await signAndSubmitTransaction({
|
|
65
|
+
data: {
|
|
66
|
+
function: "0x1::aptos_account::transfer",
|
|
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
|
+
> **Note:** Aptos has moved to the **Fungible Asset (FA) standard**. The legacy `0x1::coin::transfer<CoinType>` entry function is deprecated for anything other than native APT — don't use it for new integrations. For a Fungible Asset token (USDC, USDT, or any custom FA), call `0x1::primary_fungible_store::transfer` instead:
|
|
78
|
+
>
|
|
79
|
+
> ```typescript
|
|
80
|
+
> await signAndSubmitTransaction({
|
|
81
|
+
> data: {
|
|
82
|
+
> function: '0x1::primary_fungible_store::transfer',
|
|
83
|
+
> typeArguments: ['0x1::fungible_asset::Metadata'],
|
|
84
|
+
> functionArguments: [assetMetadataAddress, recipientAddress, amount],
|
|
85
|
+
> }
|
|
86
|
+
> });
|
|
87
|
+
> ```
|
|
88
|
+
>
|
|
89
|
+
> Works exactly the same way through SmoothSend — gasless sponsorship is chain/standard-agnostic, it just routes whatever entry function you call. This is also how SmoothSend's own demo app ([`chains/aptos/smoothsend-demo`](https://github.com/SmoothSend/smoothsendapifrontend)) builds every transfer.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### useSmoothSend Hook (Per-Function Routing)
|
|
94
|
+
|
|
95
|
+
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.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { useSmoothSend, SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
|
|
99
|
+
|
|
100
|
+
// Create once at module scope (not inside the component)
|
|
101
|
+
const submitter = new SmoothSendTransactionSubmitter({
|
|
102
|
+
apiKey: process.env.NEXT_PUBLIC_SMOOTHSEND_API_KEY!,
|
|
103
|
+
network: 'testnet',
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
function MyComponent() {
|
|
107
|
+
// Drop-in replacement for useWallet().signAndSubmitTransaction
|
|
108
|
+
const { signAndSubmitTransaction } = useSmoothSend(submitter);
|
|
109
|
+
|
|
110
|
+
const handleAction = async () => {
|
|
111
|
+
// Automatically routed:
|
|
112
|
+
// function in allowlist → fee-payer gasless (user pays 0 gas)
|
|
113
|
+
// function not in list → walletSignAndSubmit fallback (user pays gas)
|
|
114
|
+
await signAndSubmitTransaction({
|
|
115
|
+
data: {
|
|
116
|
+
function: '0xABC::mymodule::my_function',
|
|
117
|
+
functionArguments: [arg1, arg2],
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
> **Note:** Do NOT use `transactionSubmitter` in `AptosWalletAdapterProvider` when using `useSmoothSend` — the hook handles all routing directly.
|
|
125
|
+
>
|
|
126
|
+
> **Requirements:** `react >= 17`, `@aptos-labs/wallet-adapter-react >= 8`, `@aptos-labs/ts-sdk >= 5.0.0`
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### True Gasless (Backend)
|
|
131
|
+
|
|
132
|
+
For Node.js backends running 100% sponsored transactions for arbitrary generic payloads using a secret key.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { TrueGaslessClient } from '@smoothsend/sdk';
|
|
136
|
+
import { Account, Ed25519PrivateKey } from '@aptos-labs/ts-sdk';
|
|
137
|
+
|
|
138
|
+
// 1. Instantiate the backend account (keep your private key safe!)
|
|
139
|
+
const backendWallet = Account.fromPrivateKey({
|
|
140
|
+
privateKey: new Ed25519PrivateKey(process.env.APTOS_PRIVATE_KEY!)
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// 2. Create client using your secret key
|
|
144
|
+
const client = new TrueGaslessClient({
|
|
145
|
+
apiKey: process.env.SMOOTHSEND_SECRET_KEY!, // sk_nogas_*
|
|
146
|
+
network: 'mainnet'
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// 3. Build & execute your Move transaction payload
|
|
150
|
+
const result = await client.execute({
|
|
151
|
+
senderAccount: backendWallet,
|
|
152
|
+
payload: {
|
|
153
|
+
function: "0x12b...::nft::mint_to",
|
|
154
|
+
functionArguments: [recipientAddress, "1"]
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
console.log('Gasless transaction executed:', result.txHash);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### Script Composer — Fee-in-Token Transfers
|
|
164
|
+
|
|
165
|
+
For mainnet with the free tier, Script Composer deducts fees from the token being transferred rather than requiring APT.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import { ScriptComposerClient } from '@smoothsend/sdk';
|
|
169
|
+
|
|
170
|
+
const client = new ScriptComposerClient({
|
|
171
|
+
apiKey: 'pk_nogas_your_api_key',
|
|
172
|
+
network: 'mainnet'
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Step 1: Build transfer (fee calculated automatically)
|
|
176
|
+
const { transactionBytes, fee, totalAmount } = await client.buildTransfer({
|
|
177
|
+
sender: wallet.address,
|
|
178
|
+
recipient: '0x123...',
|
|
179
|
+
amount: '1000000', // 1 USDC
|
|
180
|
+
assetType: '0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b', // USDC Fungible Asset metadata address (mainnet)
|
|
181
|
+
decimals: 6,
|
|
182
|
+
symbol: 'USDC'
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
console.log(`Sending 1 USDC, fee: ${fee} (deducted from token)`);
|
|
186
|
+
|
|
187
|
+
// Step 2: Sign with wallet
|
|
188
|
+
const signedTx = await wallet.signTransaction(transactionBytes);
|
|
189
|
+
|
|
190
|
+
// Step 3: Submit
|
|
191
|
+
const result = await client.submitSignedTransaction({
|
|
192
|
+
transactionBytes: signedTx.transactionBytes,
|
|
193
|
+
authenticatorBytes: signedTx.authenticatorBytes
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
console.log('Transaction:', result.txHash);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Additional `ScriptComposerClient` methods:
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
// Estimate fee without building a transaction
|
|
203
|
+
const estimate = await client.estimateFee({
|
|
204
|
+
sender: '0x...',
|
|
205
|
+
recipient: '0x...',
|
|
206
|
+
amount: '1000000',
|
|
207
|
+
assetType: USDC_ADDRESS,
|
|
208
|
+
decimals: 6,
|
|
209
|
+
symbol: 'USDC'
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
console.log('Fee:', estimate.estimation.formatted.fee);
|
|
213
|
+
console.log('Total:', estimate.estimation.formatted.totalAmount);
|
|
214
|
+
|
|
215
|
+
// Or use the convenience method for the complete flow
|
|
216
|
+
const result = await client.transfer(transferParams, wallet);
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Choosing an Integration
|
|
222
|
+
|
|
223
|
+
| Scenario | Method | Notes |
|
|
224
|
+
|---|---|---|
|
|
225
|
+
| Make ALL transactions gasless, zero config | `transactionSubmitter` in `AptosWalletAdapterProvider` | Simplest setup |
|
|
226
|
+
| Sponsor only specific functions (allowlist) | `useSmoothSend(submitter)` hook | Per-function routing |
|
|
227
|
+
| Testnet (any tier) | `TransactionSubmitter` | Always free on testnet |
|
|
228
|
+
| Mainnet + Free tier | `ScriptComposerClient` | Fee deducted from token (~$0.01/tx) |
|
|
229
|
+
| Mainnet + Paid tier | `TransactionSubmitter` | Zero fees included in subscription |
|
|
230
|
+
| Swaps, NFTs, contracts | `TransactionSubmitter` | Script Composer supports transfers only |
|
|
231
|
+
| Token transfers you want to monetize | `ScriptComposerClient` | Pass the fee cost to your users |
|
|
232
|
+
| Backend / server-side transactions | `TrueGaslessClient` | Requires secret key (`sk_nogas_*`) |
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Avalanche — Gasless ERC-4337 Transactions
|
|
237
|
+
|
|
238
|
+
**Scope: Avalanche C-Chain mainnet and Fuji testnet only (ERC-4337, EntryPoint v0.7). No Avalanche L1 (subnet) support yet.** This integration is in beta.
|
|
239
|
+
|
|
240
|
+
Use a separate entry point (`@smoothsend/sdk/avax`) for a smaller bundle — only AVAX + viem dependencies are included.
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import { SmoothSendAvaxProvider, useSmoothSendWrite } from '@smoothsend/sdk/avax';
|
|
244
|
+
|
|
245
|
+
// 1. Wrap your app root (works alongside your existing wagmi config)
|
|
246
|
+
function App() {
|
|
247
|
+
return (
|
|
248
|
+
<SmoothSendAvaxProvider apiKey="pk_nogas_your_api_key" network="testnet">
|
|
249
|
+
<YourApp />
|
|
250
|
+
</SmoothSendAvaxProvider>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// 2. Drop-in replacement for wagmi's useWriteContract
|
|
255
|
+
function SendButton() {
|
|
256
|
+
const { writeContract } = useSmoothSendWrite();
|
|
257
|
+
|
|
258
|
+
const handleSend = () => {
|
|
259
|
+
writeContract({
|
|
260
|
+
address: tokenAddress,
|
|
261
|
+
abi: erc20Abi,
|
|
262
|
+
functionName: 'transfer',
|
|
263
|
+
args: [recipient, amount],
|
|
264
|
+
// mode: 'developer-sponsored' (default, user pays $0 gas) or 'user-pays-erc20'
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
return <button onClick={handleSend}>Send (Gasless!)</button>;
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Using Privy embedded wallets instead of wagmi? Use `useSmoothSendPrivyWrite` with the same call shape.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Stellar — Gasless XLM & USDC (testnet only, beta)
|
|
277
|
+
|
|
278
|
+
Same 3-line API for Stellar. Works with Freighter, Stellar Wallets Kit, or any Stellar-compatible wallet.
|
|
279
|
+
|
|
280
|
+
**Stellar testnet is live. Stellar mainnet is not supported yet** — the gateway rejects mainnet Stellar requests today.
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
import { SmoothSendSDK } from '@smoothsend/sdk';
|
|
284
|
+
|
|
285
|
+
const sdk = new SmoothSendSDK({ apiKey: 'pk_nogas_xxx', network: 'testnet' });
|
|
286
|
+
|
|
287
|
+
// Option 1: Full transfer (build + sign + submit)
|
|
288
|
+
const result = await sdk.transfer(
|
|
289
|
+
{ from: 'G...', to: 'G...', amount: '100', token: 'XLM', chain: 'stellar-testnet' },
|
|
290
|
+
stellarWallet
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
// Option 2: Submit pre-signed XDR
|
|
294
|
+
const signedXdr = await wallet.signTransaction(tx);
|
|
295
|
+
const result = await sdk.submitStellarTransaction(signedXdr);
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Stellar wallet interface:**
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
const stellarWallet = {
|
|
302
|
+
buildTransaction: (params) => buildPaymentTransaction(params.from, params.to, params.amount, params.token),
|
|
303
|
+
signTransaction: (tx) => walletKit.signTransaction(tx.toXDR()).then(r => r.signedTxXdr),
|
|
304
|
+
};
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Supported Networks
|
|
310
|
+
|
|
311
|
+
| Network | Status | Features |
|
|
312
|
+
|---|---|---|
|
|
313
|
+
| Aptos Testnet | ✅ Active | Gasless transactions, Ed25519 signatures |
|
|
314
|
+
| Aptos Mainnet | ✅ Active | Gasless transactions, fee-in-token option |
|
|
315
|
+
| Avalanche Fuji (testnet) | ✅ Active (beta) | ERC-4337 account abstraction, wagmi/Privy hooks |
|
|
316
|
+
| Avalanche C-Chain (mainnet) | ✅ Active (beta) | ERC-4337 account abstraction, wagmi/Privy hooks |
|
|
317
|
+
| Avalanche L1 (subnets) | 🚧 Not yet supported | — |
|
|
318
|
+
| Stellar Testnet | ✅ Active (beta) | Gasless XLM, USDC, EURC via Fee Bump |
|
|
319
|
+
| Stellar Mainnet | 🚧 Not yet supported | — |
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## Authentication
|
|
324
|
+
|
|
325
|
+
SmoothSend uses two types of API keys:
|
|
326
|
+
|
|
327
|
+
### Public Keys (`pk_nogas_*`)
|
|
328
|
+
|
|
329
|
+
- Safe for frontend applications — can be embedded in client-side code
|
|
330
|
+
- CORS-protected — only work from configured domains
|
|
331
|
+
- Use in: React apps, Vue apps, browser extensions, mobile apps
|
|
332
|
+
|
|
333
|
+
### Secret Keys (`sk_nogas_*`)
|
|
334
|
+
|
|
335
|
+
- Server-side only — must never be exposed in client-side code
|
|
336
|
+
- No CORS restrictions — work from any server environment
|
|
337
|
+
- Use in: Node.js backends, serverless functions, API servers
|
|
338
|
+
|
|
339
|
+
### Getting Your API Keys
|
|
340
|
+
|
|
341
|
+
1. Sign up at [dashboard.smoothsend.xyz](https://dashboard.smoothsend.xyz)
|
|
342
|
+
2. Create a project
|
|
343
|
+
3. Generate an API key pair — you'll receive both a public and secret key
|
|
344
|
+
4. Configure CORS origins for your public key
|
|
345
|
+
|
|
346
|
+
### Security Best Practices
|
|
347
|
+
|
|
348
|
+
- ⚠️ Never commit secret keys to version control
|
|
349
|
+
- ⚠️ Never expose secret keys in client-side code
|
|
350
|
+
- ✅ Use public keys for frontend applications
|
|
351
|
+
- ✅ Use secret keys for backend services only
|
|
352
|
+
- ✅ Configure CORS origins for all production domains
|
|
353
|
+
- ✅ All transactions require user signature approval — private keys never leave the client
|
|
354
|
+
- ✅ Rate limiting and input validation are enforced on all relayer endpoints
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## MCP Server
|
|
359
|
+
|
|
360
|
+
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.
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
npm install -g @smoothsend/mcp
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Once installed, add it to your MCP client config:
|
|
367
|
+
|
|
368
|
+
**Claude Desktop** (`claude_desktop_config.json`):
|
|
369
|
+
|
|
370
|
+
```json
|
|
371
|
+
{
|
|
372
|
+
"mcpServers": {
|
|
373
|
+
"smoothsend": {
|
|
374
|
+
"command": "smoothsend-mcp"
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Cursor** (`.cursor/mcp.json`):
|
|
381
|
+
|
|
382
|
+
```json
|
|
383
|
+
{
|
|
384
|
+
"mcpServers": {
|
|
385
|
+
"smoothsend": {
|
|
386
|
+
"command": "smoothsend-mcp"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
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.
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## Links
|
|
397
|
+
|
|
398
|
+
- **Dashboard**: [dashboard.smoothsend.xyz](https://dashboard.smoothsend.xyz)
|
|
399
|
+
- **Documentation**: [docs.smoothsend.xyz](https://docs.smoothsend.xyz)
|
|
400
|
+
- **GitHub**: [github.com/smoothsend](https://github.com/smoothsend)
|
|
401
|
+
|
|
402
|
+
## License
|
|
403
|
+
|
|
404
|
+
MIT
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
Built with ❤️ by the SmoothSend team
|