@smoothsend/sdk 2.2.0 β 2.2.2
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 +121 -201
- package/dist/avax/SmoothSendAvaxSubmitter.d.ts +79 -0
- package/dist/avax/SmoothSendAvaxSubmitter.d.ts.map +1 -0
- package/dist/avax/index.d.ts +7 -0
- package/dist/avax/index.d.ts.map +1 -0
- package/dist/avax/publicAaDefaults.d.ts +16 -0
- package/dist/avax/publicAaDefaults.d.ts.map +1 -0
- package/dist/avax/simpleAccountFactory.d.ts +44 -0
- package/dist/avax/simpleAccountFactory.d.ts.map +1 -0
- package/dist/avax/types.d.ts +86 -0
- package/dist/avax/types.d.ts.map +1 -0
- package/dist/avax/useSmoothSendAvax.d.ts +60 -0
- package/dist/avax/useSmoothSendAvax.d.ts.map +1 -0
- package/dist/avax/viemHelpers.d.ts +40 -0
- package/dist/avax/viemHelpers.d.ts.map +1 -0
- package/dist/index.d.ts +440 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2370 -131
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2390 -133
- package/dist/index.js.map +1 -1
- package/dist/session/SmoothSendSession.d.ts +1 -6
- package/dist/session/SmoothSendSession.d.ts.map +1 -1
- package/dist/session/constants.d.ts +17 -0
- package/dist/session/constants.d.ts.map +1 -0
- package/dist/true-gasless/TrueGaslessClient.d.ts +72 -0
- package/dist/true-gasless/TrueGaslessClient.d.ts.map +1 -0
- package/dist/true-gasless/index.d.ts +2 -0
- package/dist/true-gasless/index.d.ts.map +1 -0
- package/dist/utils/http.d.ts +2 -0
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/wallet-adapter/SmoothSendTransactionSubmitter.d.ts +53 -2
- package/dist/wallet-adapter/SmoothSendTransactionSubmitter.d.ts.map +1 -1
- package/dist/wallet-adapter/useSmoothSend.d.ts +10 -5
- package/dist/wallet-adapter/useSmoothSend.d.ts.map +1 -1
- package/package.json +18 -7
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Multi-chain gasless transaction SDK. Enable gas-free transactions with just 3 li
|
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Features
|
|
10
10
|
|
|
11
11
|
- **Gasless Transactions**: Users don't need APT or XLM for gas fees
|
|
12
12
|
- **Multi-Chain**: Aptos + Stellar (same 3-line API)
|
|
@@ -15,13 +15,17 @@ Multi-chain gasless transaction SDK. Enable gas-free transactions with just 3 li
|
|
|
15
15
|
- **Testnet & Mainnet**: Supports both networks on each chain
|
|
16
16
|
- **Fee-in-Token**: On Aptos mainnet, tiny fee deducted from token (not APT)
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Installation
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
21
|
npm install @smoothsend/sdk
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### Wallet Adapter (EASIEST β All Transactions Gasless)
|
|
25
29
|
|
|
26
30
|
The simplest integration β pass `transactionSubmitter` to your wallet provider and **every transaction becomes gasless automatically**. Ideal when you want to sponsor all functions.
|
|
27
31
|
|
|
@@ -72,7 +76,7 @@ function TransferButton() {
|
|
|
72
76
|
|
|
73
77
|
---
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
### useSmoothSend Hook (Per-Function Routing)
|
|
76
80
|
|
|
77
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.
|
|
78
82
|
|
|
@@ -103,31 +107,52 @@ function MyComponent() {
|
|
|
103
107
|
}
|
|
104
108
|
```
|
|
105
109
|
|
|
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)
|
|
110
117
|
|
|
111
|
-
|
|
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
|
+
});
|
|
112
134
|
|
|
113
|
-
|
|
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
|
+
});
|
|
114
143
|
|
|
115
|
-
|
|
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` |
|
|
144
|
+
console.log('Gasless transaction executed:', result.txHash);
|
|
145
|
+
```
|
|
120
146
|
|
|
121
147
|
---
|
|
122
148
|
|
|
123
|
-
|
|
149
|
+
### Script Composer β Fee-in-Token Transfers
|
|
124
150
|
|
|
125
|
-
For
|
|
151
|
+
For mainnet with the free tier, Script Composer deducts fees from the token being transferred rather than requiring APT.
|
|
126
152
|
|
|
127
153
|
```typescript
|
|
128
154
|
import { ScriptComposerClient } from '@smoothsend/sdk';
|
|
129
155
|
|
|
130
|
-
// Create client for mainnet
|
|
131
156
|
const client = new ScriptComposerClient({
|
|
132
157
|
apiKey: 'pk_nogas_your_api_key',
|
|
133
158
|
network: 'mainnet'
|
|
@@ -157,20 +182,10 @@ const result = await client.submitSignedTransaction({
|
|
|
157
182
|
console.log('Transaction:', result.txHash);
|
|
158
183
|
```
|
|
159
184
|
|
|
160
|
-
|
|
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
|
|
185
|
+
Additional `ScriptComposerClient` methods:
|
|
171
186
|
|
|
172
187
|
```typescript
|
|
173
|
-
// Estimate fee without building transaction
|
|
188
|
+
// Estimate fee without building a transaction
|
|
174
189
|
const estimate = await client.estimateFee({
|
|
175
190
|
sender: '0x...',
|
|
176
191
|
recipient: '0x...',
|
|
@@ -183,112 +198,30 @@ const estimate = await client.estimateFee({
|
|
|
183
198
|
console.log('Fee:', estimate.estimation.formatted.fee);
|
|
184
199
|
console.log('Total:', estimate.estimation.formatted.totalAmount);
|
|
185
200
|
|
|
186
|
-
// Or use the convenience method for complete flow
|
|
201
|
+
// Or use the convenience method for the complete flow
|
|
187
202
|
const result = await client.transfer(transferParams, wallet);
|
|
188
203
|
```
|
|
189
204
|
|
|
190
205
|
---
|
|
191
206
|
|
|
192
|
-
##
|
|
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
|
-
});
|
|
207
|
+
## Choosing an Integration
|
|
282
208
|
|
|
283
|
-
|
|
284
|
-
|
|
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_*`) |
|
|
285
219
|
|
|
286
|
-
|
|
287
|
-
```
|
|
220
|
+
---
|
|
288
221
|
|
|
289
|
-
##
|
|
222
|
+
## Stellar β Gasless XLM & USDC
|
|
290
223
|
|
|
291
|
-
Same 3-line API for Stellar.
|
|
224
|
+
Same 3-line API for Stellar. Works with Freighter, Stellar Wallets Kit, or any Stellar-compatible wallet.
|
|
292
225
|
|
|
293
226
|
```typescript
|
|
294
227
|
import { SmoothSendSDK } from '@smoothsend/sdk';
|
|
@@ -307,6 +240,7 @@ const result = await sdk.submitStellarTransaction(signedXdr);
|
|
|
307
240
|
```
|
|
308
241
|
|
|
309
242
|
**Stellar wallet interface:**
|
|
243
|
+
|
|
310
244
|
```typescript
|
|
311
245
|
const stellarWallet = {
|
|
312
246
|
buildTransaction: (params) => buildPaymentTransaction(params.from, params.to, params.amount, params.token),
|
|
@@ -314,116 +248,102 @@ const stellarWallet = {
|
|
|
314
248
|
};
|
|
315
249
|
```
|
|
316
250
|
|
|
317
|
-
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Supported Networks
|
|
318
254
|
|
|
319
255
|
| Network | Status | Features |
|
|
320
|
-
|
|
256
|
+
|---|---|---|
|
|
321
257
|
| Aptos Testnet | β
Active | Gasless transactions, Ed25519 signatures |
|
|
322
|
-
| Aptos Mainnet | β
Active | Gasless transactions,
|
|
258
|
+
| Aptos Mainnet | β
Active | Gasless transactions, fee-in-token option |
|
|
323
259
|
| Stellar Testnet | β
Active | Gasless XLM, USDC, EURC via Fee Bump |
|
|
324
260
|
| Stellar Mainnet | β
Active | Gasless XLM, USDC, EURC via Fee Bump |
|
|
325
261
|
|
|
326
|
-
|
|
262
|
+
---
|
|
327
263
|
|
|
328
|
-
|
|
264
|
+
## Authentication
|
|
329
265
|
|
|
330
|
-
|
|
266
|
+
SmoothSend uses two types of API keys:
|
|
331
267
|
|
|
332
|
-
|
|
333
|
-
import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
|
|
268
|
+
### Public Keys (`pk_nogas_*`)
|
|
334
269
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
});
|
|
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
|
|
339
273
|
|
|
340
|
-
|
|
341
|
-
<AptosWalletAdapterProvider
|
|
342
|
-
dappConfig={{
|
|
343
|
-
network: Network.TESTNET,
|
|
344
|
-
transactionSubmitter: submitter
|
|
345
|
-
}}
|
|
346
|
-
>
|
|
347
|
-
```
|
|
274
|
+
### Secret Keys (`sk_nogas_*`)
|
|
348
275
|
|
|
349
|
-
|
|
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
|
|
350
279
|
|
|
351
|
-
|
|
280
|
+
### Getting Your API Keys
|
|
352
281
|
|
|
353
|
-
|
|
354
|
-
|
|
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
|
|
355
286
|
|
|
356
|
-
|
|
357
|
-
apiKey: 'pk_nogas_your_api_key',
|
|
358
|
-
network: 'mainnet'
|
|
359
|
-
});
|
|
287
|
+
### Security Best Practices
|
|
360
288
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
symbol: 'USDC'
|
|
369
|
-
});
|
|
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
|
|
370
296
|
|
|
371
|
-
|
|
372
|
-
const estimate = await client.estimateFee(transferParams);
|
|
297
|
+
---
|
|
373
298
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
authenticatorBytes
|
|
378
|
-
});
|
|
379
|
-
```
|
|
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.
|
|
380
302
|
|
|
381
|
-
|
|
303
|
+
```bash
|
|
304
|
+
npm install -g @smoothsend/mcp
|
|
305
|
+
```
|
|
382
306
|
|
|
383
|
-
|
|
307
|
+
Once installed, add it to your MCP client config:
|
|
384
308
|
|
|
385
|
-
|
|
386
|
-
import { SmoothSendSDK } from '@smoothsend/sdk';
|
|
309
|
+
**Claude Desktop** (`claude_desktop_config.json`):
|
|
387
310
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
311
|
+
```json
|
|
312
|
+
{
|
|
313
|
+
"mcpServers": {
|
|
314
|
+
"smoothsend": {
|
|
315
|
+
"command": "smoothsend-mcp"
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
```
|
|
394
320
|
|
|
395
|
-
|
|
396
|
-
const result = await smoothSend.executeGaslessTransfer({
|
|
397
|
-
transactionBytes: signedTx.transactionBytes,
|
|
398
|
-
authenticatorBytes: signedTx.authenticatorBytes,
|
|
399
|
-
chain: 'aptos-testnet',
|
|
400
|
-
network: 'testnet'
|
|
401
|
-
});
|
|
321
|
+
**Cursor** (`.cursor/mcp.json`):
|
|
402
322
|
|
|
403
|
-
|
|
404
|
-
|
|
323
|
+
```json
|
|
324
|
+
{
|
|
325
|
+
"mcpServers": {
|
|
326
|
+
"smoothsend": {
|
|
327
|
+
"command": "smoothsend-mcp"
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
405
331
|
```
|
|
406
332
|
|
|
407
|
-
|
|
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.
|
|
408
334
|
|
|
409
|
-
|
|
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
|
|
335
|
+
---
|
|
415
336
|
|
|
416
|
-
##
|
|
337
|
+
## Links
|
|
417
338
|
|
|
418
339
|
- **Dashboard**: [dashboard.smoothsend.xyz](https://dashboard.smoothsend.xyz)
|
|
419
340
|
- **Documentation**: [docs.smoothsend.xyz](https://docs.smoothsend.xyz)
|
|
420
341
|
- **GitHub**: [github.com/smoothsend](https://github.com/smoothsend)
|
|
421
342
|
|
|
422
|
-
##
|
|
343
|
+
## License
|
|
423
344
|
|
|
424
345
|
MIT
|
|
425
346
|
|
|
426
347
|
---
|
|
427
348
|
|
|
428
349
|
Built with β€οΈ by the SmoothSend team
|
|
429
|
-
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Avalanche ERC-4337 (EntryPoint v0.7) via SmoothSend gateway β same idea as Aptos submitter.
|
|
3
|
+
*
|
|
4
|
+
* Minimal dApp flow:
|
|
5
|
+
* ```ts
|
|
6
|
+
* const avax = new SmoothSendAvaxSubmitter({ apiKey, network: 'testnet' });
|
|
7
|
+
* await avax.submitSponsoredUserOperation({ userOp: draft, signUserOp: wallet.sign });
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
import type { AvaxSponsorshipMode, GasEstimateAvax, PaymasterSignRequestAvax, PaymasterSignResponseAvax, SponsoredUserOpDraftAvax, UserOperationAvax, UserOperationReceiptAvax } from './types';
|
|
11
|
+
/** Options for {@link SmoothSendAvaxSubmitter.submitSponsoredUserOperation} */
|
|
12
|
+
export interface SubmitSponsoredAvaxUserOpOptions {
|
|
13
|
+
/** Sender must match your smart account; nonce/callData/fees from your app */
|
|
14
|
+
userOp: SponsoredUserOpDraftAvax;
|
|
15
|
+
/** Wallet / viem / ethers signs the UserOp hash your stack expects */
|
|
16
|
+
signUserOp: (userOp: UserOperationAvax) => Promise<string>;
|
|
17
|
+
mode?: AvaxSponsorshipMode;
|
|
18
|
+
/** Defaults to first entry point from `eth_supportedEntryPoints` */
|
|
19
|
+
entryPoint?: string;
|
|
20
|
+
/** Extra `paymaster/sign` fields (`token`, `receiver`, β¦) for user-pays-ERC20 */
|
|
21
|
+
paymaster?: Omit<PaymasterSignRequestAvax, 'mode' | 'userOp'>;
|
|
22
|
+
/** @default true */
|
|
23
|
+
waitForReceipt?: boolean;
|
|
24
|
+
receiptPoll?: {
|
|
25
|
+
pollMs?: number;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface SmoothSendAvaxSubmitterConfig {
|
|
30
|
+
apiKey: string;
|
|
31
|
+
network?: 'testnet' | 'mainnet';
|
|
32
|
+
gatewayUrl?: string;
|
|
33
|
+
timeout?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Gateway chain routing bucket. Default `avalanche` matches `core/gateway` routing.
|
|
36
|
+
*/
|
|
37
|
+
chain?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Public keys (`pk_nogas_*`) require an `Origin` header matching your project's allowed CORS origins.
|
|
40
|
+
* Set this for Node/scripts (e.g. `http://localhost:5173`). Browsers send Origin automatically.
|
|
41
|
+
*/
|
|
42
|
+
corsOrigin?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare class SmoothSendAvaxSubmitter {
|
|
45
|
+
private readonly config;
|
|
46
|
+
private readonly http;
|
|
47
|
+
private rpcId;
|
|
48
|
+
constructor(config: SmoothSendAvaxSubmitterConfig);
|
|
49
|
+
getConfig(): Readonly<SmoothSendAvaxSubmitterConfig>;
|
|
50
|
+
/** Merge gas estimate fields into a partial UserOp */
|
|
51
|
+
static applyGasEstimate(userOp: UserOperationAvax, gas: GasEstimateAvax): UserOperationAvax;
|
|
52
|
+
/** Attach packed paymaster data returned from {@link paymasterSign} */
|
|
53
|
+
static applyPaymasterAndData(userOp: UserOperationAvax, paymasterAndData: string): UserOperationAvax;
|
|
54
|
+
getChainId(): Promise<string>;
|
|
55
|
+
getSupportedEntryPoints(): Promise<string[]>;
|
|
56
|
+
estimateUserOperationGas(userOp: UserOperationAvax, entryPoint: string): Promise<GasEstimateAvax>;
|
|
57
|
+
sendUserOperation(userOp: UserOperationAvax, entryPoint: string): Promise<string>;
|
|
58
|
+
getUserOperationReceipt(userOpHash: string): Promise<UserOperationReceiptAvax | null>;
|
|
59
|
+
waitForUserOperationReceipt(userOpHash: string, options?: {
|
|
60
|
+
pollMs?: number;
|
|
61
|
+
timeoutMs?: number;
|
|
62
|
+
}): Promise<UserOperationReceiptAvax | null>;
|
|
63
|
+
paymasterSign(body: PaymasterSignRequestAvax): Promise<PaymasterSignResponseAvax>;
|
|
64
|
+
getBundlerHealth(): Promise<unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* One call: estimate gas β paymaster/sign β merge β your sign β send β (optional) wait for receipt.
|
|
67
|
+
*/
|
|
68
|
+
submitSponsoredUserOperation(opts: SubmitSponsoredAvaxUserOpOptions): Promise<{
|
|
69
|
+
userOpHash: string;
|
|
70
|
+
receipt: UserOperationReceiptAvax | null;
|
|
71
|
+
}>;
|
|
72
|
+
private rpc;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @alias {@link SmoothSendAvaxSubmitter}
|
|
76
|
+
*/
|
|
77
|
+
export declare const AvaxSubmitter: typeof SmoothSendAvaxSubmitter;
|
|
78
|
+
export declare function createSmoothSendAvaxSubmitter(config: SmoothSendAvaxSubmitterConfig): SmoothSendAvaxSubmitter;
|
|
79
|
+
//# sourceMappingURL=SmoothSendAvaxSubmitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmoothSendAvaxSubmitter.d.ts","sourceRoot":"","sources":["../../src/avax/SmoothSendAvaxSubmitter.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { AvaxSponsorshipMode, GasEstimateAvax, JsonRpcResponseAvax, PaymasterSignRequestAvax, PaymasterSignResponseAvax, SponsoredUserOpDraftAvax, UserOperationAvax, UserOperationReceiptAvax, } from './types';
|
|
2
|
+
export { AvaxSubmitter, SmoothSendAvaxSubmitter, createSmoothSendAvaxSubmitter, type SmoothSendAvaxSubmitterConfig, type SubmitSponsoredAvaxUserOpOptions, } from './SmoothSendAvaxSubmitter';
|
|
3
|
+
export { avaxExecuteAbi, encodeAvaxExecuteCalldata, hashUserOperationAvax, readAvaxSenderNonce, userOperationAvaxToViem, } from './viemHelpers';
|
|
4
|
+
export { SIMPLE_ACCOUNT_FACTORY_ABI, encodeCreateAccountFactoryData, predictSimpleAccountAddress, } from './simpleAccountFactory';
|
|
5
|
+
export { ENTRY_POINT_V07_ADDRESS, fetchAvaxAaPublicDefaults, type AvaxAaPublicDefaults, } from './publicAaDefaults';
|
|
6
|
+
export { SmoothSendAvaxProvider, useSmoothSendAvax, useSmoothSendAvaxContext, type SmoothSendAvaxContextValue, type UseSmoothSendAvaxParams, } from './useSmoothSendAvax';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/avax/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,6BAA6B,EAC7B,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,GACtC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,GAC7B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public gateway defaults for Avalanche AA (no API key).
|
|
3
|
+
*/
|
|
4
|
+
/** Canonical ERC-4337 EntryPoint v0.7 on Fuji / Avalanche C-Chain */
|
|
5
|
+
export declare const ENTRY_POINT_V07_ADDRESS: "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
6
|
+
export type AvaxAaPublicDefaults = {
|
|
7
|
+
success?: boolean;
|
|
8
|
+
simpleAccountFactoryFuji: `0x${string}` | null;
|
|
9
|
+
entryPointV07: typeof ENTRY_POINT_V07_ADDRESS;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Fetch SimpleAccount factory hint from SmoothSend gateway (GET; no auth).
|
|
13
|
+
* Ops configure {@link https://proxy.smoothsend.xyz} `AVAX_FUJI_SIMPLE_ACCOUNT_FACTORY`; until then this returns null.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fetchAvaxAaPublicDefaults(gatewayUrl?: string): Promise<AvaxAaPublicDefaults>;
|
|
16
|
+
//# sourceMappingURL=publicAaDefaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publicAaDefaults.d.ts","sourceRoot":"","sources":["../../src/avax/publicAaDefaults.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,EAClC,4CAAqD,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wBAAwB,EAAE,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;IAC/C,aAAa,EAAE,OAAO,uBAAuB,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,SAAiC,GAC1C,OAAO,CAAC,oBAAoB,CAAC,CA0B/B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard SimpleAccountFactory (EntryPoint v0.7) helpers for counterfactual address + init calldata.
|
|
3
|
+
*/
|
|
4
|
+
import type { Address, Hex, PublicClient } from 'viem';
|
|
5
|
+
/** Minimal ABI for eth-infinitismβstyle SimpleAccountFactory. */
|
|
6
|
+
export declare const SIMPLE_ACCOUNT_FACTORY_ABI: readonly [{
|
|
7
|
+
readonly inputs: readonly [{
|
|
8
|
+
readonly name: "owner";
|
|
9
|
+
readonly type: "address";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "salt";
|
|
12
|
+
readonly type: "uint256";
|
|
13
|
+
}];
|
|
14
|
+
readonly name: "createAccount";
|
|
15
|
+
readonly outputs: readonly [{
|
|
16
|
+
readonly name: "account";
|
|
17
|
+
readonly type: "address";
|
|
18
|
+
}];
|
|
19
|
+
readonly stateMutability: "nonpayable";
|
|
20
|
+
readonly type: "function";
|
|
21
|
+
}, {
|
|
22
|
+
readonly inputs: readonly [{
|
|
23
|
+
readonly name: "owner";
|
|
24
|
+
readonly type: "address";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "salt";
|
|
27
|
+
readonly type: "uint256";
|
|
28
|
+
}];
|
|
29
|
+
readonly name: "getAddress";
|
|
30
|
+
readonly outputs: readonly [{
|
|
31
|
+
readonly name: "";
|
|
32
|
+
readonly type: "address";
|
|
33
|
+
}];
|
|
34
|
+
readonly stateMutability: "view";
|
|
35
|
+
readonly type: "function";
|
|
36
|
+
}];
|
|
37
|
+
export declare function predictSimpleAccountAddress(params: {
|
|
38
|
+
publicClient: PublicClient;
|
|
39
|
+
factory: Address;
|
|
40
|
+
owner: Address;
|
|
41
|
+
salt?: bigint;
|
|
42
|
+
}): Promise<Address>;
|
|
43
|
+
export declare function encodeCreateAccountFactoryData(owner: Address, salt: bigint): Hex;
|
|
44
|
+
//# sourceMappingURL=simpleAccountFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simpleAccountFactory.d.ts","sourceRoot":"","sources":["../../src/avax/simpleAccountFactory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIvD,iEAAiE;AACjE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqB7B,CAAC;AAEX,wBAAsB,2BAA2B,CAAC,MAAM,EAAE;IACxD,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,OAAO,CAAC,CASnB;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,GACX,GAAG,CAML"}
|