External vs Public Function Gas Comparator
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 connects to your EVM wallet and compares the gas costs of external versus public functions in smart contracts. It reads contract source code to identify functions with external and public visibility, then optionally uses gas snapshot data to compare the actual gas costs of each function. The tool provides a clear comparison table showing gas costs for each function, highlighting the difference between external and public visibility choices.
HOW TO USE
Connect your Web3 wallet using the Connect button. Paste your contract source code in the Contract Source Code field. Optionally, provide gas snapshot data in JSON format in the Gas Data field—this should include gas costs for external and public functions. Click "Compare Functions" to analyze visibility and gas costs. Click "Load Sample" to populate fields with an example contract and gas data. Results appear in the Results card with a summary of functions found, external vs public counts, and a detailed comparison table showing function names, visibility, gas costs, and differences.
TECHNICAL MECHANISM: VISIBILITY ANALYSIS WITH OPTIONAL GAS COMPARISON
The tool uses regular expression pattern matching to parse contract source code and identify function declarations with external or public visibility. It extracts function names and their visibility modifiers. If gas snapshot data is provided, the tool matches each function against the gas data to display external and public gas costs. The difference between public and external gas costs is calculated and color-coded (red for higher public cost, green for lower, amber for equal). The tool also provides recommendations based on the analysis—suggesting external visibility for functions that are only called externally to save gas.
WHAT IT CANNOT SEE
This tool cannot generate gas snapshots or execute test runs itself—it requires external gas data for cost comparison. It cannot compare gas costs for functions with different parameter types or complexity—the comparison assumes similar function bodies. It cannot account for compiler optimizations or EVM version differences—gas costs vary with compiler settings. It relies on external test data or manual input for gas comparisons—the tool does not measure gas directly. It cannot determine if visibility choice is optimal without runtime context—the best visibility depends on how the function is used.
PLEASE NOTE
This is a read-only tool—it never signs transactions. All data is processed in-memory and never persists. The tool supports EVM chains only—Ethereum, Polygon, BSC, Arbitrum, Optimism, Avalanche, Base, and Fantom. External functions are generally cheaper than public functions for calldata parameters, but the best choice depends on your contract's usage patterns. Use gas snapshots from Hardhat Gas Reporter or Foundry for accurate comparisons.