canSponsorUserOperation
Checks if a user operation can be sponsored by the configured paymaster. Works for both single transactions and batch transactions. This is useful to determine if the user will need to pay gas fees or if the operation qualifies for gas sponsorship.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 |
Returns
Promise<boolean> - Returns true if the user operation can be sponsored, false otherwise.
Examples
Single transaction with wallet account
Batch transaction
Using existing kernel client
Related functions
- sendUserOperation - Send a user operation (single or batch)
- estimateUserOperationGas - Estimate gas for a user operation
- createKernelClientForWalletAccount - Create a ZeroDev Kernel client
- isGasSponsorshipError - Check if an error is a gas sponsorship error