Most-Expensive-Function Identifier
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
This tool analyzes historical transaction data for any specified contract to identify which functions consume the most gas. By scanning logs across a user-defined block range, it extracts the 4-byte method ID from each transaction's calldata, fetches the corresponding transaction receipt, and calculates the total gas cost (effectiveGasPrice × gasUsed) for each function call. The results are aggregated per function and presented as a ranked list showing total ETH spent, average cost per call, call count, and percentage of total gas consumption. A visual bar chart highlights the most expensive functions, and a prominent "most expensive" badge draws attention to the single costliest function. This is essential for developers optimizing gas costs, auditors identifying inefficient functions, and project teams prioritizing refactoring efforts to reduce user transaction fees.
HOW TO USE
Connect your wallet (read-only, no transaction required) and select the target network. Enter the contract address you want to analyze, specify the block range (start and end blocks), and set a chunk size for log scanning. Click "find most expensive functions" and the tool will scan the specified range, extracting method IDs and calculating gas costs for every transaction interacting with the contract. Results display as a ranked frequency table with cost breakdowns, accompanied by a visual bar chart of the top 20 costliest functions. A highlighted "most expensive" section shows the single function that has consumed the most total gas across all calls. Use this data to identify optimization targets, prioritize code refactoring, and reduce your users' transaction costs.
TECHNICAL MECHANISM
The analyzer uses ethers.js v5.7.2 to perform eth_getLogs queries against the specified contract address, automatically handling RPC rate limits through a chunk-and-halve strategy. Starting with the user-defined chunk size, it scans the block range sequentially; if a query fails due to provider limits, it halves the chunk size and retries, ensuring the scan progresses even with restrictive RPC endpoints. For each log found, the tool fetches the associated transaction receipt and transaction data, extracting the first 4 bytes of calldata (the method ID). It then calculates the true gas cost using receipt.effectiveGasPrice (the actual price paid after EIP-1559, not the tx.gasPrice cap) multiplied by receipt.gasUsed. These costs are aggregated per method ID, with totals and averages computed across all calls. The results are sorted by total gas cost descending, with percentages calculated relative to the total gas spent across all functions. The implementation deduplicates transaction hashes and processes logs in batches to optimize performance while respecting RPC concurrency limits.
WHAT IT CANNOT SEE
This tool cannot analyze contracts that do not emit events or logs, as it relies on log emissions to detect transactions. It cannot see internal transactions or delegate calls that do not produce logs, meaning functions invoked via DELEGATECALL or internal contract calls may be invisible. Gas cost calculations are based on historical data and may not reflect current network conditions, gas prices, or contract state. Method ID matching may produce false positives if different functions share the same 4-byte signature. The tool cannot account for variable gas costs based on input parameters or off-chain gas optimization strategies. It cannot analyze transactions where the contract interaction did not emit a log. It is limited by the RPC provider's historical block range availability and rate limits. The accuracy of results depends on the completeness and reliability of the underlying RPC data and the contract's log emissions.
PLEASE NOTE
This is a read‑only analytics tool—it never submits transactions or signs anything. It is designed for EVM‑compatible chains. For best results, use an archival RPC node with broad historical access. The tool works best on contracts that emit events on every transaction; contracts without logs will produce no results. Gas costs are shown in ETH (or the native currency of the chain) for clarity and comparability.