This app runs inside the BotSurf browser. Don't have it yet? Get the app or extension now!

Gas Profiler Per-Function Breakdown Tool

Developer Tools · All
0 installs · Verified BotGentz app
Launch App
Opens in BotSurf — nothing to install.
CategoryDeveloper Tools
PlatformAll
Pricing Free
Installs0
Download BotSurf to use — free
No account needed for free apps. Once BotSurf is open, find this app in Apps from the + menu.

About this app

WHAT IT DOES

Gas Profiler Per-Function Breakdown Tool is a read-only developer tool that analyzes gas usage across smart contract functions by examining historical transaction data. It reads contract bytecode to map all available functions, fetches transaction histories and receipts to extract per-call gas costs using effectiveGasPrice (post-EIP-1559), and aggregates metrics including average gas per function, minimum and maximum gas usage, success rates, and average cost in native tokens. The tool provides a detailed breakdown table and visualizations, helping developers identify gas-heavy functions, optimize expensive operations, and estimate gas costs for contract updates. It also surfaces transaction failure patterns and function call frequency to prioritize optimization efforts.

HOW TO USE

Connect your EVM-compatible wallet via the BGWallet bridge and select the network where your contract is deployed. Enter the contract address and specify the number of recent transactions to analyze (1-100). Click "Profile Gas Usage" to start the analysis. The tool fetches transaction receipts using chunked log scanning that automatically halves request ranges if RPCs reject full-range queries, ensuring compatibility with public and private RPC providers. Results include a function-by-function breakdown showing call counts, average gas, min/max gas, success rates, and average cost in ETH, plus a visual bar chart comparing average gas usage across functions. All analysis is read-only—no signatures or transactions are submitted.

TECHNICAL MECHANISM

The tool uses ethers.js v5.7.2 with a robust chunked log fetching strategy to handle provider-specific eth_getLogs limits. It first fetches the contract's bytecode via provider.getCode(address), then extracts function signatures by scanning for 0x63 PUSH4 opcodes to identify all 4-byte selectors. For transaction history, the tool constructs a log filter for the contract address and fetches logs using a recursive chunking algorithm: starting from a large block range, if a request fails due to response size limits, it halves the range and recursively fetches both halves, continuing until successful. This prevents providers from refusing large queries and ensures data completeness. From each transaction hash, the tool retrieves the transaction details and receipt, extracting gasUsed and effectiveGasPrice (using effectiveGasPrice over gasPrice to accurately reflect post-EIP-1559 costs). Each transaction is matched to a function selector by parsing the input data's first 4 bytes. The tool then aggregates per-function statistics: total gas, average gas, min/max, success/fail counts, and total cost, calculating cost in ETH by multiplying gasUsed by effectiveGasPrice and converting from wei. Results are sorted by call frequency and rendered with a bar chart for visual comparison.

WHAT IT CANNOT SEE

This tool has fundamental limitations that users must understand. It cannot simulate arbitrary transaction input permutations to test all execution paths—it only analyzes functions that have been called historically, so functions with zero on-chain activity will not appear. It cannot predict gas costs on different chains or under different network conditions, as gas prices and base fees vary dramatically across networks and over time. It cannot determine gas costs for functions that require specific state conditions not present in historical transactions—unusual execution paths or edge cases that have not been triggered on-chain remain unmeasured. It cannot provide execution gas breakdown for unverified or obfuscated bytecode where function boundaries are unclear—without clear function signatures, the tool cannot map transactions to specific functions. It cannot account for gas costs of internal calls or sub-calls within a function, only the total gas consumed by the top-level transaction. It cannot capture private transactions or failed transactions that are not recorded in the public blockchain. It cannot analyze contracts with no transaction history or on testnets with sparse activity. The tool's data is retrospective and cannot forecast future gas usage after contract upgrades.

PLEASE NOTE

This tool only supports EVM-compatible blockchains (Ethereum, Polygon, BSC, Avalanche C-Chain, Optimism, Arbitrum, and their testnets). Solana, Tron, Starknet, SUI, TON, Aptos, Bitcoin, Cosmos, and XRP are not supported. The tool is free, open-source, requires no API keys, and uses the wallet's native provider for all read operations. Gas costs are presented as estimates based on historical data; actual gas costs may vary based on current network conditions.

Similar Apps

Log in to BotGentz

Suggest an App

Tell us what you'd find useful — if we build it, we'll email you the moment it's ready.