sendUserOperation
Sends a user operation with one or more calls and waits for the transaction receipt. Works for both single transactions and batch transactions. This is the primary function for executing transactions with ZeroDev Account Abstraction.Usage
Parameters
You must provide either awalletAccount or a kernelClient, but not both.
| Parameter | Type | Description |
|---|---|---|
calls | BatchCall[] | Array of calls to execute (single or multiple) |
calls[].to | Hex | The recipient address for this call |
calls[].value | bigint | The value to send in wei for this call |
calls[].data | Hex (optional) | The transaction data for this call |
walletAccount | EvmWalletAccount (optional) | The wallet account. Required if no kernelClient is provided |
kernelClient | KernelClient (optional) | An existing kernel client. Required if no walletAccount is provided |
withSponsorship | boolean (optional) | Whether to use sponsorship. Default: true. Only used with walletAccount |
Returns
Promise<UserOperationReceipt> - Returns the UserOperation receipt with transaction details.
The receipt includes:
userOpHash: The UserOperation hashsuccess: Boolean indicating if the operation succeeded- Additional transaction details from the receipt
Examples
Single transaction (sponsored by default)
Batch transaction (multiple recipients)
Without sponsorship (user pays gas)
Using existing kernel client
Token transfer
DeFi workflow (Approve + Swap)
With gas estimation and sponsorship check
Error handling
Benefits of Batch Transactions
- Atomicity: All operations succeed or all fail together
- Cost Efficiency: Single validation per batch reduces gas fees
- Better UX: Users approve once for multiple operations
- Composability: Enable complex multi-step workflows
Notes
- By default, transactions use sponsorship (
withSponsorship: true) - Batch transactions are atomic - if any call fails, the entire batch fails
- The function waits for the UserOperation receipt before returning
- Gas savings increase with larger batches due to shared validation costs
Related functions
- estimateUserOperationGas - Estimate gas for a user operation
- canSponsorUserOperation - Check if operation can be sponsored
- createKernelClientForWalletAccount - Create a ZeroDev Kernel client
- isGasSponsorshipError - Check if an error is a gas sponsorship error