Documentation>AVAX API Reference

AVAX API Reference

ERC-4337 APIs from @smoothsend/sdk/avax.

Imports
TypeScript
import {
SmoothSendAvaxClient,
createSmoothSendAvaxClient,
SmoothSendAvaxSubmitter,
createSmoothSendAvaxSubmitter,
SmoothSendAvaxProvider,
useSmoothSendAvax,
encodeAvaxExecuteCalldata,
encodeAvaxExecuteBatchCalldata,
hashUserOperationAvax,
readAvaxSenderNonce,
} from '@smoothsend/sdk/avax';
SmoothSendAvaxClient
Recommended high-level client for most integrations.

Constructor

TypeScript
createSmoothSendAvaxClient({
apiKey: string,
network?: 'testnet' | 'mainnet',
gatewayUrl?: string,
timeout?: number,
chain?: string,
})

Key methods

TypeScript
submitCall(opts): Promise<{ userOpHash: string; receipt: UserOperationReceiptAvax | null; hashTypes?: { userOpHash: string; transactionHash?: string } }>
submitCalls(opts): Promise<{ userOpHash: string; receipt: UserOperationReceiptAvax | null; hashTypes?: { userOpHash: string; transactionHash?: string } }>
estimateUserPaysFee(opts): Promise<{ feePreview?: AvaxFeePreview; exchangeRate?: PaymasterSignResponseAvax['exchangeRate'] }>
SmoothSendAvaxSubmitter (advanced)
Low-level client for direct bundler JSON-RPC and paymaster operations.

Constructor

TypeScript
new SmoothSendAvaxSubmitter({
apiKey: string,
network?: 'testnet' | 'mainnet',
gatewayUrl?: string,
timeout?: number,
chain?: string, // default: 'avalanche'
corsOrigin?: string, // required for pk_nogas_* in non-browser scripts
})

Key methods

TypeScript
getChainId(): Promise<string>
getSupportedEntryPoints(): Promise<string[]>
estimateUserOperationGas(userOp, entryPoint): Promise<GasEstimateAvax>
sendUserOperation(userOp, entryPoint): Promise<string>
getUserOperationReceipt(userOpHash): Promise<UserOperationReceiptAvax | null>
paymasterSign(body): Promise<PaymasterSignResponseAvax>
estimateUserPaysFee(input): Promise<{ feePreview?: AvaxFeePreview; exchangeRate?: PaymasterSignResponseAvax['exchangeRate'] }>
submitSponsoredUserOperation(opts): Promise<{ userOpHash: string; receipt: UserOperationReceiptAvax | null }>
submitSponsoredUserOperation options
Low-level API — pass a pre-encoded userOp with your own callData. Use useSmoothSendAvax from React for the high-level hook that handles encoding automatically.
TypeScript
{
userOp: SponsoredUserOpDraftAvax,
signUserOp: (userOp: UserOperationAvax) => Promise<string>,
mode?: 'developer-sponsored' | 'user-pays-erc20',
entryPoint?: string,
paymaster?: {
token?: string;
receiver?: string;
precheckBalance?: boolean;
prepaymentRequired?: boolean;
validUntil?: number;
validAfter?: number;
postOpGas?: number;
allowAnyBundler?: boolean;
},
waitForReceipt?: boolean,
receiptPoll?: { pollMs?: number; timeoutMs?: number },
}
React API — useSmoothSendAvax
Hook-based frontend integration with wagmi public/wallet clients. Handles callData encoding, nonce fetching, fee estimation, and UserOp signing automatically.
TypeScript
<SmoothSendAvaxProvider
apiKey="pk_nogas_xxx"
network="testnet"
smartAccountAddress="0x..."
>
<App />
</SmoothSendAvaxProvider>
TypeScript
const { submitCall, submitSponsoredUserOp } = useSmoothSendAvax({
publicClient,
walletClient,
});
 
// Single call — encodes via execute(dest, value, func)
await submitCall({ to, data, mode: 'developer-sponsored' });
 
// Batch — encodes via executeBatch(dest[], value[], func[])
await submitSponsoredUserOp({
calls: [
{ to: tokenAddress, data: approveCalldata, value: 0n },
{ to: tokenAddress, data: transferCalldata, value: 0n },
],
sponsorshipMode: 'user-pays-erc20',
paymaster: { token: usdcAddress },
});
Helpers

encodeAvaxExecuteCalldata(to, value, data): encodes a single smart account execute calldata.

encodeAvaxExecuteBatchCalldata(dest[], value[], func[]): encodes an executeBatch calldata for atomic multi-call UserOperations. All three arrays must be the same length.

fetchAvaxAaPublicDefaults(gatewayUrl?): fetches the latest EntryPoint, SimpleAccountFactory, and Paymaster addresses for Fuji and Mainnet from the gateway. Use this to avoid hardcoding contract addresses in your app.

readAvaxSenderNonce({ publicClient, entryPointAddress, sender }): reads nonce from EntryPoint for a sender address.

hashUserOperationAvax({ chainId, entryPointAddress, userOperation }): builds the EIP-4337 userOp hash for wallet signing.