Skip to content

How to Estimate the Gas Limits for a User Operation

We recommend using permissionless.js to estimate user operations gas limits as it provides type-safe wrappers for all bundler methods.

To estimate the gas limits for a user operation, you need to use your Pimlico API key and make a JSON-RPC request as follows:

import { createClient, http } from "viem"
const pimlicoApiKey = "YOUR_PIMLICO_API_KEY_HERE"
const chain = "sepolia" // find the list of supported chains at
const pimlicoEndpoint = `${chain}/rpc?apikey=${pimlicoApiKey}`
const userOperation = ...
const entryPoint = "0x0000000071727De22E5E9d8BAf0edAc6f37da032"
const pimlicoClient = createClient({ transport: http(pimlicoEndpoint) })
const estimationResult = await pimlicoClient.request({ 
    method: "eth_estimateUserOperationGas", 
    params: [userOperation, entryPoint] 
const preVerificationGas = estimationResult.preVerificationGas
const verificationGasLimit = estimationResult.verificationGasLimit
const callGasLimit = estimationResult.callGasLimit
const paymasterVerificationGasLimit = estimationResult.paymasterVerificationGasLimit
const paymasterPostOpGasLimit = estimationResult.paymasterPostOpGasLimit