Skip to content

eth_estimateUserOperationGas

This method simulates the user operation and estimates the appropriate gas limits for it.

If the operation is not successful, it will return an error.

Request

{
    "jsonrpc": "2.0",
    "method": "eth_estimateUserOperationGas",
    "params": [
        {
            "sender":"0xa203fDb8bC335F86016F635b85389B62B189E417",
            "nonce":"0x35bf2a054f92f3730b87582ef223c8d663f9eb01158154750000000000000000",
            "initCode":"0x",
            "callData":"0xb61d27f6000000000000000000000000530fff22987e137e7c8d2adcc4c15eb45b4fa752000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000184165398be00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000002fcf1000000000000000000000000000000000000000000000000000000e8d4ac25fd000000000000000000000000000000000000000000000000000001d1a94f86e3000000000000000000000000000000000000000000000000000000e8d4ac13d6000000000000000000000000000000000000000000000000000001d1a94edaef000000000000000000000000000000000000000000000000000000e8d4ac25fa00000000000000000000000000000000000000000000000000000000",
            "callGasLimit":"0x115b5c0",
            "verificationGasLimit":"0x249f0",
            "preVerificationGas":"0xeb11",
            "maxPriorityFeePerGas":"0x12a05f200",
            "maxFeePerGas":"0x5b08082fa",
            "paymasterAndData":"0x",
            "signature":"0xa6cc6589c8bd561cfd68d7b6b0757ef6f208e7438782939938498eee7d703260137856c840c491b3d415956265e81bf5c2184a725be2abfc365f7536b6af525e1c"
        },
        "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
    ],
    "id": 1
}

Response

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

Using state overrides

You can use state overrides to simulate the user operation with a different state the same way you would with eth_call by including an optional third parameter.

{
    "jsonrpc": "2.0",
    "method": "eth_estimateUserOperationGas",
    "params": [
        {
            "sender":"0xa203fDb8bC335F86016F635b85389B62B189E417",
            "nonce":"0x35bf2a054f92f3730b87582ef223c8d663f9eb01158154750000000000000000",
            "initCode":"0x",
            "callData":"0xb61d27f6000000000000000000000000530fff22987e137e7c8d2adcc4c15eb45b4fa752000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000184165398be00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000002fcf1000000000000000000000000000000000000000000000000000000e8d4ac25fd000000000000000000000000000000000000000000000000000001d1a94f86e3000000000000000000000000000000000000000000000000000000e8d4ac13d6000000000000000000000000000000000000000000000000000001d1a94edaef000000000000000000000000000000000000000000000000000000e8d4ac25fa00000000000000000000000000000000000000000000000000000000",
            "callGasLimit":"0x115b5c0",
            "verificationGasLimit":"0x249f0",
            "preVerificationGas":"0xeb11",
            "maxPriorityFeePerGas":"0x12a05f200",
            "maxFeePerGas":"0x5b08082fa",
            "paymasterAndData":"0x",
            "signature":"0xa6cc6589c8bd561cfd68d7b6b0757ef6f208e7438782939938498eee7d703260137856c840c491b3d415956265e81bf5c2184a725be2abfc365f7536b6af525e1c"
        },
        "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
        {
            "0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3": {
                "balance": "0xde0b6b3a7640000"
            },
            "0xebe8efa441b9302a0d7eaecc277c09d20d684540": {
                "stateDiff": {
                    "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80": "0x21"
                }
            }
        }
        
    ],
    "id": 1
}