AVAX API Reference
ERC-4337 APIs from @smoothsend/sdk/avax.
import { SmoothSendAvaxClient, createSmoothSendAvaxClient, SmoothSendAvaxSubmitter, createSmoothSendAvaxSubmitter, SmoothSendAvaxProvider, useSmoothSendAvax, encodeAvaxExecuteCalldata, encodeAvaxExecuteBatchCalldata, hashUserOperationAvax, readAvaxSenderNonce,} from '@smoothsend/sdk/avax';Constructor
createSmoothSendAvaxClient({ apiKey: string, network?: 'testnet' | 'mainnet', gatewayUrl?: string, timeout?: number, chain?: string,})Key methods
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'] }>Constructor
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
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 }>userOp with your own callData. Use useSmoothSendAvax from React for the high-level hook that handles encoding automatically.{ 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 },}<SmoothSendAvaxProvider apiKey="pk_nogas_xxx" network="testnet" smartAccountAddress="0x..."> <App /></SmoothSendAvaxProvider>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 },});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.