npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@biconomy/gas-estimations

v0.2.75

Published

[![codecov](https://codecov.io/gh/bcnmy/entry-point-gas-estimations/graph/badge.svg?token=YFY752HCIC)](https://codecov.io/gh/bcnmy/entry-point-gas-estimations)

Readme

Biconomy Gas Estimations

codecov

A utility package that performs simulation and estimations of all ERC-4337 User Operation gas limits.

Quickstart:

bun add @biconomy/gas-estimations viem

Usage

Create a Gas Estimator

You can create the gas estimator for you chain of choice in multiple ways.

❌ Don't use public RPC URLs because they often don't support more advanced features like state overrides and debug_traceCall

Using a chainId and a rpcUrl:

import { mainnet } from "viem/chains"

const gasEstimator = createGasEstimator({
  chainId: mainnet.id,
  rpc: "https://rpc.url",
});

Using a viem public client:

import { mainnet } from "viem/chains"

const viemClient = createPublicClient({
  chain: miannet,
  transport: http("https://rpc.url"),
});

const gasEstimator = createGasEstimator({
  chainId: testChain.chainId,
  rpc: viemClient,
});

Or using a full chain specification (useful for new chains not supported by default by this package):

const customChain: SupportedChain = {
  chainId: 4337,
  name: "Biconomy Mainnet",
  isTestnet: false,
  stack: ChainStack.Optimism,
  eip1559: true,
  entryPoints: {
    [EntryPointVersion.v060]: {
      address: "0x006",
    },
    [EntryPointVersion.v070]: {
      address: "0x007",
    },
  },
  stateOverrideSupport: {
    balance: true,
    bytecode: true,
    stateDiff: true,
  },
  smartAccountSupport: {
    smartAccountsV2: true,
    nexus: true,
  },
  simulation: {
    preVerificationGas: 1n,
    verificationGasLimit: 2n,
    callGasLimit: 3n,
  },
  paymasters: DEFAULT_PAYMASTERS,
};

const gasEstimator = createGasEstimator({
  chainId: customChain.chainId,
  rpc: rpcUrl,
  chain: customChain,
});

Estimating User Operation gas limits

By default the gas estimator tries to be as flexible as possible and return the gas estimates, even if the sender (or the paymaster) doesn't have funds to pay for gas.

💡 If the target chain (or your RPC provider) doesn't support state overrides, the estimation will fail if the on-chain requirements (such as sender and paymaster balance) are not met and there's not much we can do.

const gasEstimate =
  await gasEstimator.estimateUserOperationGas({
    unEstimatedUserOperation: userOperation,
    baseFeePerGas,
  });

Simulation mode

In case you don't want the package to perform any state overrides by default you can use the simulation mode and the package will throw an appropriate error if the sender doesn't have enough balance or any other on-chain requirement is not met.

await gasEstimator.estimateUserOperationGas({
  unEstimatedUserOperation: userOperation,
  baseFeePerGas,
  options: {
    simulation: true
  }
});

Passing custom state overrides

You can pass additional state overrides when estimating, there's a helper StateOverrideBuilder you can use:

await gasEstimator.estimateUserOperationGas({
  unEstimatedUserOperation: userOperation,
  baseFeePerGas,
  stateOverrides: new StateOverrideBuilder().
    .overrideBalance(
      address,
      parseEther("100"),
    )
    .overridePaymasterDeposit(
      entryPointAddress,
      paymasterAddress
    )
    .build()
});

API Reference

For detailed documentation and API reference, visit our api documentation here.

Building

To build the project do bun run build

Publishing

Production Release

To publish a new production version:

  1. Create a new changeset (documents your changes):
bun run changeset
  1. Version the package (updates package.json and changelog):
bun run changeset:version
  1. Publish to npm:
bun run changeset:release

Canary Release

To publish a canary (preview) version:

bun run changeset:release:canary

This will publish a canary version to npm with a temporary version number. The original package.json will be restored automatically after publishing.

Canary Release

Note: You need to have appropriate npm permissions to publish the package.

Linking & Developing

To link the package to your project, run:

bun run dev

Then in your linked project, update your package.json dependencies to point to the local SDK:

{
  "dependencies": {
    "@biconomy/gas-estimations": "file:../../entry-point-gas-estimations"
  }
}

This will run the package in watch mode, and will automatically update the package in your linked project.