Skip to main content

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 a walletAccount or a kernelClient, but not both.

Returns

Promise<UserOperationReceipt> - Returns the UserOperation receipt with transaction details. The receipt includes:
  • userOpHash: The UserOperation hash
  • success: 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

React

Use sendUserOperation inside a button handler. Use useGetWalletAccounts from @dynamic-labs-sdk/react-hooks to reactively get the wallet account:

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
Last modified on June 24, 2026