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.

EntryPoint v0.7

Request

{
  "jsonrpc": "2.0",
  "method": "eth_estimateUserOperationGas",
  "params": [
    {
      "sender": "0x5a6b47F4131bf1feAFA56A05573314BcF44C9149",
      "nonce": "0x845adb2c711129d4f3966735ed98a9f09fc4ce5700000000000000000000",
      "factory": "0xd703aaE79538628d27099B8c4f621bE4CCd142d5",
      "factoryData": "0xc5265d5d000000000000000000000000aac5d4240af87249b3f71bc8e4a2cae074a3e4190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000014375d883Cb4afb913aC35c4B394468C4bC73d77C40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "callData": "0xe9ae5c5300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "callGasLimit": "0x0",
      "verificationGasLimit": "0x0",
      "preVerificationGas": "0x0",
      "maxFeePerGas": "0x7a5cf70d5",
      "maxPriorityFeePerGas": "0x3b9aca00",
      "paymaster": null,
      "paymasterVerificationGasLimit": null,
      "paymasterPostOpGasLimit": null,
      "paymasterData": null,
      "signature": "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",
    },
    "0x0000000071727De22E5E9d8BAf0edAc6f37da032"
  ],
  "id": 1
}

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "preVerificationGas": "0xd3e3",
    "verificationGasLimit": "0x60b01",
    "callGasLimit": "0x13880",
    "paymasterVerificationGasLimit": "0x0",
    "paymasterPostOpGasLimit": "0x0"
  }
}

EntryPoint v0.6

Request

{
  "jsonrpc": "2.0",
  "method": "eth_estimateUserOperationGas",
  "params": [
    {
      "sender":"0xb341FEAFaF71b09089d03B7D114599f8F491EE45",
      "nonce":"0x0",
      "initCode":"0x5de4839a76cf55d0c90e2061ef4386d962E15ae3296601cd0000000000000000000000000da6a956b9488ed4dd761e59f52fdc6c8068e6b5000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084d1f57894000000000000000000000000d9ab5096a832b9ce79914329daee236f8eea039000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000014375cd3E53E18f65672E9d0Eb6AD174511b0BF98100000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "callData":"0x5194544700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "callGasLimit":"0x0",
      "verificationGasLimit":"0x0",
      "preVerificationGas":"0x0",
      "maxPriorityFeePerGas":"0x3b9aca00",
      "maxFeePerGas":"0x7a5cf70d5",
      "paymasterAndData":"0x",
      "signature":"0x00000000fffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
    },
    "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
  ],
  "id": 1
}

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "preVerificationGas": "0xdf55",
    "verificationGas": "0x52503",
    "verificationGasLimit": "0x52503",
    "callGasLimit": "0x13880"
  }
}

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. This is supported for both EntryPoint v0.6 and v0.7.

{
  "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
}