eth_estimateUserOperationGas

This method provides estimates for PreVerificationGas, VerificationGas, and CallGasLimit based on a given UserOperation and EntryPoint address.

It does not validate the signature field or the current gas values; however, to ensure the most accurate results, a dummy signature, such as a correctly formatted and appropriately lengthened signature, should be used.

Request

{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "eth_estimateUserOperationGas",
    "params": [
        {
            "sender": "0x7C6EdFcdEc67c0D39AB28D77AA6933fd7Bd385AB",
            "nonce": "0x1",
            "initCode":"0x",
            "callData": "0x9faf00f4d9c8df66a69fd6242d468aa8a31a439d14fc6c7af3868a06ed392233bc7e39475df25ad2b52bd5e19e1d438277207a415cb4d4ce8ad192464c55ddf1a9559ff900000000000000000000000073da77f0f2daaa88b908413495d3d0e37458212e00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000039946fd82c9c86c9a61bceed86fbdd284590bdd90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000",
            "paymasterAndData": "0x",
            "signature": "0x00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000245eab87439bd309d66de800303f1db9a3eecb735e308681e212aef8037c3d8438b8a50ad8bfff30f44786dde7f37ea2474e016a7224107eb6557a017ee5661525000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22656b435663303542377a544a6934426a6e7453304b5a665f55317a78504a4e52365964704d32664c48786f222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000",
            "maxFeePerGas": "0x35000396b",
            "maxPriorityFeePerGas": "0xb0d24a9d",
            "callGasLimit": "0x30d40",
            "verificationGasLimit": "0x186a00",
            "preVerificationGas": "0x30d40"
        },
        "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
    ]
}

Response

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "preVerificationGas": "0xc178",
        "verificationGasLimit": "0x2a768",
        "callGasLimit": "0x225ec"
    }
}

Optional state override set

Gas estimation for a UserOperation can also be performed under various states, which is useful in multiple scenarios.

For instance, you might need to estimate the gas for an ERC-20 transfer without encountering an RPC error due to insufficient funds.

This is achieved by providing a parameter that maps addresses to their override settings.

It works the same way as eth_call.

Example

{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "eth_estimateUserOperationGas",
    "params": [
        {
            "sender": "0x7C6EdFcdEc67c0D39AB28D77AA6933fd7Bd385AB",
            "nonce": "0x1",
            "initCode":"0x",
            "callData": "0x9faf00f4d9c8df66a69fd6242d468aa8a31a439d14fc6c7af3868a06ed392233bc7e39475df25ad2b52bd5e19e1d438277207a415cb4d4ce8ad192464c55ddf1a9559ff900000000000000000000000073da77f0f2daaa88b908413495d3d0e37458212e00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000039946fd82c9c86c9a61bceed86fbdd284590bdd90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000",
            "paymasterAndData": "0x",
            "signature": "0x00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000245eab87439bd309d66de800303f1db9a3eecb735e308681e212aef8037c3d8438b8a50ad8bfff30f44786dde7f37ea2474e016a7224107eb6557a017ee5661525000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22656b435663303542377a544a6934426a6e7453304b5a665f55317a78504a4e52365964704d32664c48786f222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000",
            "maxFeePerGas": "0x35000396b",
            "maxPriorityFeePerGas": "0xb0d24a9d",
            "callGasLimit": "0x30d40",
            "verificationGasLimit": "0x186a00",
            "preVerificationGas": "0x30d40"
        },
        "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
        {
            "0x7C6EdFcdEc67c0D39AB28D77AA6933fd7Bd385AB": {
                "balance": "0xff345742234"
            }
        }
    ]
}

Last updated