estimateUserOperationGas, this function is synchronous and does not make any network
calls — it computes the fee from gas values you already have (e.g., after calling
estimateUserOperationGas or building a user operation manually).
Installation
Usage
Parameters
| Parameter | Type | Description |
|---|---|---|
userOperationData | object | Gas values for the user operation |
userOperationData.callGasLimit | bigint | Gas limit for the call phase |
userOperationData.verificationGasLimit | bigint | Gas limit for the verification phase |
userOperationData.preVerificationGas | bigint | Fixed pre-verification gas overhead |
userOperationData.maxFeePerGas | bigint | Maximum fee per gas unit in wei |
networkData | NetworkData | Network configuration. Get this from getNetworksData() |
nativeTokenPriceUsd | number (optional) | USD price of the native token, used to calculate usdAmount |
Returns
EvmTransactionFeeData (synchronous — not a Promise):
| Field | Type | Description |
|---|---|---|
nativeAmount | bigint | Total fee in wei: (callGasLimit + verificationGasLimit + preVerificationGas) × maxFeePerGas |
humanReadableAmount | string | Fee in ETH, formatted for display |
usdAmount | string (optional) | Fee in USD. Present only when nativeTokenPriceUsd is provided |
gasEstimate | bigint | Total gas units: callGasLimit + verificationGasLimit + preVerificationGas |
maxFeePerGas | bigint | The maxFeePerGas value passed in |
Examples
Display fee before sending
With USD conversion
Error handling
Related functions
- estimateUserOperationGas - Estimate gas cost for a user operation (makes network calls)
- simulateZerodevUserOperation - Full simulation with asset diffs and security validation
- sendUserOperation - Send a user operation
- calculateEvmTransactionFee - Fee estimation for standard EVM transactions
- getNetworksData - Get network configuration objects