
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@biconomy/gas-estimations
Advanced tools
[](https://codecov.io/gh/bcnmy/entry-point-gas-estimations)
A utility package that performs simulation and estimations of all ERC-4337 User Operation gas limits.
bun add @biconomy/gas-estimations viem
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,
});
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,
});
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
}
});
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()
});
For detailed documentation and API reference, visit our api documentation here.
To build the project do bun run build
To publish a new production version:
bun run changeset
bun run changeset:version
bun run changeset: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.
Note: You need to have appropriate npm permissions to publish the package.
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.
FAQs
[](https://codecov.io/gh/bcnmy/entry-point-gas-estimations)
The npm package @biconomy/gas-estimations receives a total of 450 weekly downloads. As such, @biconomy/gas-estimations popularity was classified as not popular.
We found that @biconomy/gas-estimations demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.