API Reference
Complete reference for the SmoothSend SDK classes and methods
Constructor
new SmoothSendTransactionSubmitter({ apiKey: string, // Required — your pk_nogas_* or sk_nogas_* key network?: string, // 'testnet' | 'mainnet' (default: 'testnet') gatewayUrl?: string, // Override gateway URL (default: https://proxy.smoothsend.xyz) timeout?: number, // Request timeout ms (default: 30000) debug?: boolean, // Log requests/responses (default: false) getCaptchaToken?: () => Promise<string | null>, // CAPTCHA callback — see Sponsorship Rules})Methods
submitTransaction(args)Submits a signed transaction through the SmoothSend relayer. Implements the standard TransactionSubmitter interface from @aptos-labs/ts-sdk — no code changes needed in your existing wallet calls.
getSponsoredFunctions(): Promise<string[]>Fetches the list of sponsored function identifiers from your project's Sponsorship Rules. Results are cached in memory — safe to call on every render. Used internally by useSmoothSend.
isSponsored(functionName: string): Promise<boolean>Returns true if the given function identifier (e.g. 0x1::module::function) is in the project's sponsored allowlist. Calls getSponsoredFunctions() internally.
Usage
1import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';2import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react';3import { Network } from '@aptos-labs/ts-sdk';4 5const submitter = new SmoothSendTransactionSubmitter({6 apiKey: process.env.NEXT_PUBLIC_SMOOTHSEND_API_KEY!,7 network: 'mainnet',8});9 10// Pass to provider — all wallet transactions are now gasless11export function Providers({ children }: { children: React.ReactNode }) {12 return (13 <AptosWalletAdapterProvider14 dappConfig={{ network: Network.MAINNET, transactionSubmitter: submitter }}15 >16 {children}17 </AptosWalletAdapterProvider>18 );19}useWallet().signAndSubmitTransaction and routes each call based on your Sponsorship Rules allowlist: sponsored → fee-payer gasless, not sponsored → user pays gas normally.Signature
import { useSmoothSend } from '@smoothsend/sdk'; const { signAndSubmitTransaction } = useSmoothSend(submitter);Parameters
submitter: SmoothSendTransactionSubmitterA SmoothSendTransactionSubmitter instance. Create it once at module scope (not inside the component) to avoid recreating on every render.
Returns
signAndSubmitTransaction(input)Same call signature as the wallet adapter's signAndSubmitTransaction. Automatically routes: sponsored functions use fee-payer gasless path; others fall back to the user paying gas via their wallet.
Usage
1import { useSmoothSend, SmoothSendTransactionSubmitter } from '@smoothsend/sdk';2import { useWallet } from '@aptos-labs/wallet-adapter-react';3 4// Create once at module scope5const submitter = new SmoothSendTransactionSubmitter({6 apiKey: process.env.NEXT_PUBLIC_SMOOTHSEND_API_KEY!,7 network: 'mainnet',8});9 10function TodoList() {11 const { account } = useWallet();12 13 // Drop-in for useWallet().signAndSubmitTransaction14 const { signAndSubmitTransaction } = useSmoothSend(submitter);15 16 const handleDelete = async (id: number) => {17 // 'delete_todo' in sponsorship rules → gasless18 // 'create_todo' not in rules → user pays gas19 const result = await signAndSubmitTransaction({20 data: {21 function: `${MODULE_ADDRESS}::todolist::delete_todo`,22 functionArguments: [id],23 },24 });25 console.log('Tx hash:', result.hash);26 };27}Note
The wallet must support signTransaction (sign-only) for the gasless path — Petra and Nightly both support this. If the wallet does not support it, the hook automatically falls back to user-pays-gas.
Constructor
new ScriptComposerClient({ apiKey: string, network?: 'testnet' | 'mainnet', // default: 'testnet' gatewayUrl?: string, timeout?: number, debug?: boolean,})Methods
buildTransfer(params)Builds a Script Composer transfer. Returns transactionBytes and a feeBreakdown — show the fee to users before they sign.
submitSignedTransaction(params)Submits the signed transaction. Returns { txHash: string }.
estimateFee(params)Quick fee estimate without building the full transaction. Useful for showing fees in the UI before the user initiates a transfer.
buildTransfer params
{ sender: string, // Wallet address of the sender recipient: string, // Destination address amount: string, // Amount in smallest units (e.g. '1000000' = 1 USDC) assetType: string, // Token contract address (see Supported Tokens below) decimals: number, // Token decimals (e.g. 6 for USDC) symbol: string, // Token symbol (e.g. 'USDC')}| Symbol | Name | Decimals | Mainnet assetType |
|---|---|---|---|
| USDC | USD Coin | 6 | 0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b |
| USDT | Tether USD | 6 | 0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b |
| WBTC | Wrapped Bitcoin | 8 | 0x68c2185f5e2023f2e4401ba56b66c8ae2cfcf8a27852e70eb78b03f59a652a3d |
| USDe | USDe (Ethena) | 6 | 0xf37a4a75f89b79985c1fcb42d0a87f4bde28cc2b46c4dd01d9a8428e7726e2e9 |
| USD1 | USD1 (World Liberty) | 6 | 0x05fa02d0fa44a90ad59fb90adb08e24c4efbc98eb9e9f2d0d9c0ad18d7fc9d2 |
SmoothSendError on failure. Always wrap in try/catch.1import { SmoothSendError } from '@smoothsend/sdk';2 3try {4 const result = await signAndSubmitTransaction(transaction);5 console.log('Success:', result.hash);6} catch (error) {7 if (error instanceof SmoothSendError) {8 switch (error.statusCode) {9 case 401: console.error('Invalid API key'); break;10 case 402: console.error('Insufficient credits — top up your dashboard'); break;11 case 429: console.error('Rate limit exceeded — slow down requests'); break;12 default: console.error('SmoothSend error:', error.message);13 }14 } else {15 console.error('Wallet or network error:', error);16 }17}