Documentation>API Reference

API Reference

Complete reference for the SmoothSend SDK classes and methods

SmoothSendTransactionSubmitter
Drop-in transaction submitter for the Aptos Wallet Adapter. Handles any transaction type — transfers, contract calls, NFT mints, DeFi. Credits deducted on mainnet.

Constructor

TypeScript
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

App.tsx
TypeScript
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 gasless
11export function Providers({ children }: { children: React.ReactNode }) {
12 return (
13 <AptosWalletAdapterProvider
14 dappConfig={{ network: Network.MAINNET, transactionSubmitter: submitter }}
15 >
16 {children}
17 </AptosWalletAdapterProvider>
18 );
19}
useSmoothSend
React hook for automatic per-function gasless routing. Replaces useWallet().signAndSubmitTransaction and routes each call based on your Sponsorship Rules allowlist: sponsored → fee-payer gasless, not sponsored → user pays gas normally.

Signature

TypeScript
import { useSmoothSend } from '@smoothsend/sdk';
 
const { signAndSubmitTransaction } = useSmoothSend(submitter);

Parameters

submitter: SmoothSendTransactionSubmitter

A 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

TodoList.tsx
TypeScript
1import { useSmoothSend, SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
2import { useWallet } from '@aptos-labs/wallet-adapter-react';
3 
4// Create once at module scope
5const 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().signAndSubmitTransaction
14 const { signAndSubmitTransaction } = useSmoothSend(submitter);
15 
16 const handleDelete = async (id: number) => {
17 // 'delete_todo' in sponsorship rules → gasless
18 // 'create_todo' not in rules → user pays gas
19 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.

ScriptComposerClient
Builds fee-in-token transfers for mainnet stablecoins. No credits required — the relayer fee is deducted directly from the token being sent.

Constructor

TypeScript
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

TypeScript
{
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')
}
Supported Tokens — Script Composer
Mainnet stablecoin asset addresses for use with ScriptComposerClient. Testnet supports the same symbols on the Aptos testnet.
SymbolNameDecimalsMainnet assetType
USDCUSD Coin60xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b
USDTTether USD60x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b
WBTCWrapped Bitcoin80x68c2185f5e2023f2e4401ba56b66c8ae2cfcf8a27852e70eb78b03f59a652a3d
USDeUSDe (Ethena)60xf37a4a75f89b79985c1fcb42d0a87f4bde28cc2b46c4dd01d9a8428e7726e2e9
USD1USD1 (World Liberty)60x05fa02d0fa44a90ad59fb90adb08e24c4efbc98eb9e9f2d0d9c0ad18d7fc9d2
Error Handling
Both classes throw SmoothSendError on failure. Always wrap in try/catch.
transfer.ts
TypeScript
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}