@smoothsend/sdk 2.3.6 → 2.3.7
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 +349 -349
- package/dist/adapters/evm.d.ts +39 -0
- package/dist/adapters/evm.d.ts.map +1 -0
- package/dist/config/chains.d.ts +7 -0
- package/dist/config/chains.d.ts.map +1 -0
- package/dist/index.esm.js +3 -1846
- package/dist/index.esm.js.map +1 -1
- package/dist/services/chainConfigService.d.ts +49 -0
- package/dist/services/chainConfigService.d.ts.map +1 -0
- package/package.json +120 -120
- package/dist/aptos-privy/index.cjs +0 -40
- package/dist/aptos-privy/index.cjs.map +0 -1
- package/dist/aptos-privy/index.js +0 -34
- package/dist/aptos-privy/index.js.map +0 -1
- package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts +0 -4
- package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts.map +0 -1
- package/dist/aptos-privy/privyAptosSigner.d.ts +0 -32
- package/dist/aptos-privy/privyAptosSigner.d.ts.map +0 -1
- package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts +0 -13
- package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts.map +0 -1
- package/dist/aptos-privy-entry.d.ts +0 -9
- package/dist/aptos-privy-entry.d.ts.map +0 -1
- package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs +0 -1519
- package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs.map +0 -1
- package/dist/chunks/SmoothSendSDK-CaV_PCIG.js +0 -1511
- package/dist/chunks/SmoothSendSDK-CaV_PCIG.js.map +0 -1
- package/dist/chunks/SmoothSendSDK.d-9GBgZONY.d.ts +0 -262
- package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs +0 -1237
- package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs.map +0 -1
- package/dist/chunks/TrueGaslessClient-l2uFvNAa.js +0 -1228
- package/dist/chunks/TrueGaslessClient-l2uFvNAa.js.map +0 -1
- package/dist/chunks/shared-2xx2VLH3.js +0 -453
- package/dist/chunks/shared-2xx2VLH3.js.map +0 -1
- package/dist/chunks/shared-B8UdyBTN.d.ts +0 -143
- package/dist/chunks/shared-BJv1JV1H.cjs +0 -702
- package/dist/chunks/shared-BJv1JV1H.cjs.map +0 -1
- package/dist/chunks/shared-BXvqbQ6f.d.ts +0 -262
- package/dist/chunks/shared-Bh4xtpHv.js +0 -740
- package/dist/chunks/shared-Bh4xtpHv.js.map +0 -1
- package/dist/chunks/shared-BlIQttCf.d.ts +0 -1279
- package/dist/chunks/shared-BoRfHN1w.js +0 -1511
- package/dist/chunks/shared-BoRfHN1w.js.map +0 -1
- package/dist/chunks/shared-CNF22ESH.js +0 -557
- package/dist/chunks/shared-CNF22ESH.js.map +0 -1
- package/dist/chunks/shared-CPpb2n9T.d.ts +0 -780
- package/dist/chunks/shared-CaQMAGQR.js +0 -1511
- package/dist/chunks/shared-CaQMAGQR.js.map +0 -1
- package/dist/chunks/shared-Cgb7mhwI.d.ts +0 -471
- package/dist/chunks/shared-Cn4duBJT.d.ts +0 -1279
- package/dist/chunks/shared-CzR0rIwZ.cjs +0 -635
- package/dist/chunks/shared-CzR0rIwZ.cjs.map +0 -1
- package/dist/chunks/shared-DEurKmpI.cjs +0 -1519
- package/dist/chunks/shared-DEurKmpI.cjs.map +0 -1
- package/dist/chunks/shared-DQbEIiTE.cjs +0 -746
- package/dist/chunks/shared-DQbEIiTE.cjs.map +0 -1
- package/dist/chunks/shared-DYAVFARB.d.ts +0 -472
- package/dist/chunks/shared-DzwYUjQn.cjs +0 -457
- package/dist/chunks/shared-DzwYUjQn.cjs.map +0 -1
- package/dist/chunks/shared-KUvoQkzf.d.ts +0 -471
- package/dist/chunks/shared-RVkwmkG7.d.ts +0 -262
- package/dist/chunks/shared-XH1iLZjy.js +0 -629
- package/dist/chunks/shared-XH1iLZjy.js.map +0 -1
- package/dist/chunks/shared-kovW7ATj.js +0 -694
- package/dist/chunks/shared-kovW7ATj.js.map +0 -1
- package/dist/chunks/shared-viO0MYao.d.ts +0 -459
- package/dist/chunks/shared-x1-VC-Li.cjs +0 -568
- package/dist/chunks/shared-x1-VC-Li.cjs.map +0 -1
- package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs +0 -1865
- package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs.map +0 -1
- package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js +0 -1848
- package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js.map +0 -1
- package/dist/chunks/version-CNF22ESH.js +0 -557
- package/dist/chunks/version-CNF22ESH.js.map +0 -1
- package/dist/chunks/version-x1-VC-Li.cjs +0 -568
- package/dist/chunks/version-x1-VC-Li.cjs.map +0 -1
- package/dist/chunks/version.d-Cn4duBJT.d.ts +0 -1279
package/README.md
CHANGED
|
@@ -1,349 +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
|
-
[](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 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
|
|
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.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 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
|