debugUserOperation
This method helps debug User Operations by providing detailed information about the operation, including packed format, RPC parameters, and optional Tenderly simulation links. Under the hood, it sends a user operation in the same way as sendUserOperation, but with additional debugging information.
Usage
import { nexusClient } from "./nexusClient"
// Debug a user operation
const debug = await nexusClient.debugUserOperation({
calls: [{
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('0.1'),
data: '0x'
}]
})
Parameters
The method accepts the same parameters as sendUserOperation
, including:
calls
{ data?: Hex, to: Address, value?: bigint }[]
: Array of transactions to executeentryPointAddress
Address
(optional): Override the default EntryPoint address- All other standard User Operation parameters (gas limits, nonce, etc.)
Response
The method provides detailed debug information in the console:
- Packed User Operation format
- RPC parameters sent to the bundler
- Tenderly simulation URL (if environment variables are configured)
- User Operation hash
- Detailed error information if the operation fails
Enhanced Error Handling
The debug output includes enhanced error information powered by the aa-errors repository. When an error occurs, you'll receive:
- Error name and code
- Detailed description of the error
- Potential causes
- Suggested solutions
For example, if your smart account lacks funds, you might see:
{
"name": "SmartAccountInsufficientFundsError",
"code": "aa21",
"description": "You are not using a paymaster, and the sender address did not have enough native tokens to cover the gas costs associated with the user operation.",
"causes": [
"Your smart wallet does not have funds to send transaction."
],
"solutions": [
"If you are not using a paymaster, verify that the sender address has enough native tokens to cover the required prefund.",
"Send some native tokens in your smart wallet to be able to resolve the error.",
"If you are looking to use a paymaster to cover the gas fees, verify that the paymasterAndData field is set."
]
}
Tenderly Integration
To enable Tenderly simulation links, set the following environment variables:
TENDERLY_API_KEY=your_api_key
TENDERLY_ACCOUNT_SLUG=your_account_slug
TENDERLY_PROJECT_SLUG=your_project_slug
When enabled, you'll get access to Tenderly's simulation interface:
. This is particularly useful for debugging and testing aa23 errors.
Related Methods
- sendUserOperation - For production use
- prepareUserOperation - For preparing operations without sending