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

Custom Error vs Require String Gas Comparator

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

Custom Error vs Require String Gas Comparator is a developer-focused tool that compares the gas costs of using custom errors versus require statements with string messages in Solidity contracts. It takes contract source code from the user and analyzes it for custom error declarations and require statements with string messages. The tool identifies each require statement with a string message and estimates the gas savings that could be achieved by replacing it with a custom error. It also detects existing custom errors and provides a comprehensive comparison report. Results are displayed with a summary showing the number of custom errors, require strings, total comparisons, and estimated total gas savings. Each comparison entry includes the type (custom or require), the error name or message, line number, context, and a recommendation. This enables developers to optimize gas costs by migrating from require strings to custom errors.

HOW TO USE

Paste your Solidity contract source code into the input area. Click "Compare gas costs" to analyze the code. The tool will display a summary showing the number of custom errors, require strings, total comparisons, and estimated total gas savings. Each comparison entry includes the type, name or message, line number, context, and a recommendation. The report can be copied or downloaded as JSON for further analysis.

TECHNICAL NOTE: GAS COST ESTIMATION METHODOLOGY

The tool parses the source code using regex-based pattern matching to detect error declarations and require statements. For each require statement with a string message, the tool estimates that replacing it with a custom error saves approximately 150 gas per revert. This estimate is based on the difference between storing and decoding a string error message (which incurs memory and decoding costs) versus using a custom error (which uses a 4-byte selector and optional parameters). Custom errors also reduce deployment bytecode size since they don't embed string literals. The tool also detects existing custom errors and notes when a require message could be replaced with an existing custom error, avoiding duplication. The tool classifies each comparison by type and provides actionable recommendations.

WHAT IT CANNOT SEE

The tool cannot automatically detect all gas differences without context; some require strings may be necessary for user-facing error messages. It is limited to the accuracy of the source code analysis; syntax variations may cause parsing issues. It cannot detect issues in external contracts or libraries that are imported into the contract. It is limited by the parser's ability to handle Solidity syntax variations, including newer language features. It cannot compare gas costs for non-EVM chains.

PLEASE NOTE

This tool is designed exclusively for Solidity contracts on EVM-compatible chains. It does not support other smart contract languages. The estimated gas savings are based on typical patterns and may vary depending on the specific contract and compiler version. Custom errors were introduced in Solidity 0.8.4; ensure your compiler version supports them. The tool is read-only and does not modify any state. The tool provides no warranty that the estimates are complete or accurate; users are responsible for validating all recommendations.

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.