eth_estimateUserOperationGas

Estimates the gas values for a UserOperation.

📘

NOTE

This endpoint does not require a valid signature field in userOperation. It just requires a dummy signature for gas estimation. You can use the dummy signature mentioned below when the sender account is LightAccount or SimpleAccount:

0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c

Network Support

ChainMainnetTestnet
Ethereum
Polygon
Arbitrum
Optimism
Base
Frax
Zora

Choosing an Entry Point Version

eth_estimateUserOperationGas supports versions 0.6.0 and 0.7.0 of ERC-4337. These two versions define different formats for user operations, and their entry point contracts are deployed at different addresses. Thus, when calling eth_estimateUserOperationGas, you must choose whether you want to use the 0.6.0 or 0.7.0 version of this endpoint and ensure that you are using the correct user operation format and entry point address.

Which version of the endpoint you want is determined by the smart contract account for which you are trying to send a user operation. A given smart contract account will typically be written to be compatible with either 0.6.0 or 0.7.0 and you should use that version in your request. If you're not sure which version is compatible with a smart contract account, you can look at its source code and check the first parameter to validateUserOp. If it has type UserOperation, then the account uses 0.6.0, while if it has type PackedUserOperation then the account uses 0.7.0.

For more information about the differences in versions, see the specifications for ERC-4337 v0.6.0 and ERC-4337 v0.7.0

Parameters

  1. UserOperation (Object): Contains gas limits and prices (optional). This can be either a v0.6 or v0.7 user operation but must match the version of the entry point at the address of the second parameter.

  2. entryPoint (String): The address to which the request should be sent. This must be one of the entry points returned by the supportedEntryPoints RPC call and should match the version of the user operation in the first parameter.

  3. stateOverrideSet (Object): Allows changes to the state of a contract before executing the call. For example, you can modify variable values (like balances or approvals) for that call without changing the contract itself on the blockchain.

    In more technical terms, the state override set is an optional parameter that allows executing the call against a modified chain state. It is an address-to-state mapping, where each entry specifies some state to be overridden prior to executing the call. Each address maps to an object containing:

    FIELDTYPEBYTESDESCRIPTION
    balanceQuantity<32Fake balance to set for the account before executing the call.
    nonceQuantity<8Fake nonce to set for the account before executing the call.
    codeBinaryanyFake EVM bytecode to inject into the account before executing the call.
    stateObjectanyFake key-value mapping to override all slots in the account storage before executing the call.
    stateDiffObjectanyFake key-value mapping to override individual slots in the account storage before executing the call.
Language
URL
Click Try It! to start a request and see the response here!