Skip to content

bug(account-abstraction): estimateUserOperationGas strips gas prices, causing validation failure on strict bundlers (EntryPoint 0.7) #4726

@crow-004

Description

@crow-004

Check existing issues

Viem Version

2.48.4

Current Behavior

When using smartAccountClient with EntryPoint 0.7, the internal estimateUserOperationGas action explicitly ignores/strips maxFeePerGas and maxPriorityFeePerGas before calling the JSON-RPC method eth_estimateUserOperationGas. Strict bundlers (like Pimlico v2 endpoints) reject this payload with validation errors because they expect these string/hex properties to be defined in the user operation object for EP 0.7.

Root Cause Analysis
Looking at viem/account-abstraction/actions/bundler/estimateUserOperationGas.ts:
const request = account ? await getAction(client, prepareUserOperation, 'prepareUserOperation')({ ...parameters, parameters: [ 'authorization', 'factory', 'nonce', 'paymaster', 'signature', ], }) : parameters;

The parameters array explicitly passes only specific keys to prepareUserOperation. Because gas prices (maxFeePerGas, maxPriorityFeePerGas) are omitted here, the subsequent formatUserOperationRequest(request) outputs an operation object completely stripped of gas price fields.

While some bundlers fall back gracefully, strict RPC nodes enforce the presence of these fields in EntryPoint 0.7 schema validation, causing transaction flows to break entirely.

Expected Behavior

estimateUserOperationGas should retain maxFeePerGas and maxPriorityFeePerGas if they are already resolved or provided by the gasPrice middleware/arguments, instead of filtering them out before hitting client.request.

Steps To Reproduce

  1. Set up a smartAccountClient using custom middleware hooks.
  2. In the gasPrice middleware, return calculated maxFeePerGas and maxPriorityFeePerGas.
  3. Trigger an action that invokes estimateUserOperationGas.
  4. The bundler returns: Invalid input: expected string, received undefined at "params[0].userOp.maxFeePerGas".

Link to Minimal Reproducible Example

No response

Anything else?

Environment:

Viem Version: 2.48.4 (and newer v2 releases)
Bundler: Pimlico (v2 RPC endpoint)
EntryPoint: 0.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions