Inline Assembly Gas Savings Estimator
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
The Inline Assembly Gas Savings Estimator is a developer tool that analyzes Solidity source code to estimate gas savings from inline assembly blocks. It parses contract source to identify all assembly { ... } blocks, extracts individual operations, and compares them against equivalent Solidity code patterns. The tool calculates estimated gas costs for both approaches, providing a clear picture of potential savings. This helps developers decide whether the complexity of inline assembly is justified by the gas savings it delivers.
HOW TO USE
Paste your Solidity contract source code into the analyzer. The tool processes the code, extracting all assembly blocks and analyzing their operations. Results display in clear tables showing each assembly block's estimated gas cost, equivalent Solidity gas cost, and total savings. The tool provides detailed breakdowns of individual operations within each block, including operation type, count, and per-operation savings. A comprehensive assessment categorizes the savings as significant, moderate, or minor, with specific recommendations for each case.
TECHNICAL MECHANISM
The analyzer operates through static parsing of Solidity source code, first stripping comments and string literals to avoid false positives. It scans for assembly blocks using regex patterns that match the "assembly {" syntax, tracking brace depth to extract complete block content. Each block is then analyzed for common EVM operations using a comprehensive operation cost dictionary. The tool maintains estimated gas costs for each operation in both assembly and equivalent Solidity: mstore costs 3 gas in assembly vs 20 gas in Solidity, sstore costs 100 gas in assembly vs 20,000 gas in Solidity, and keccak256 costs 30 gas in assembly vs 60 gas in Solidity. The tool sums costs across all operations in each block, calculates per-block and total savings, and expresses savings as both absolute gas values and percentages. This provides developers with actionable data to evaluate the cost-benefit trade-off of assembly usage.
WHAT IT CANNOT SEE
The tool cannot determine actual gas costs without executing the contract, as runtime conditions and dynamic assembly paths significantly affect gas usage. It cannot analyze memory management within assembly blocks or detect assembly operations that depend on runtime data. The tool cannot account for the gas impact of external calls made from assembly or predict Solidity compiler optimizations that may already optimize the equivalent code. It cannot analyze the gas impact of assembly blocks across different compiler versions or account for gas price variations. The tool cannot detect assembly operations that are intentionally used for security reasons beyond gas optimization.
PLEASE NOTE
This tool is designed for Ethereum Virtual Machine (EVM) compatible chains only. All gas estimations are approximations based on standard EVM execution costs and should be validated through testnet deployment. The analysis assumes the Solidity compiler's default optimization settings and may not account for custom optimizations or non-standard patterns. Consider the trade-off: inline assembly saves gas but reduces code readability and increases security risks. For critical applications, always verify assembly gas savings through actual transaction execution on your target network. Different Solidity compiler versions may affect both assembly and Solidity code generation, potentially altering savings calculations.