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

Unused State Variable Detector

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

This tool detects unused state variables in smart contracts by analyzing verified source code and identifying references to declared variables. It scans contract source code to find all state variable declarations, then checks each variable to determine if it is actually referenced anywhere in the contract—including reads, writes, and usage in functions, modifiers, and events. Results are presented as a detailed state variable analysis report with status indicators (used/unused/unknown), variable types, reference lists, and actionable recommendations. This is essential for developers reducing storage waste, auditors identifying dead code, and teams optimizing contract gas costs and storage footprint.

HOW TO USE

Connect your wallet (read-only, no transaction required) and select the target network. Enter the contract name and address. Click "detect unused state variables" and the tool will verify the contract, fetch its source code, and analyze all state variable declarations for actual usage. Results display a summary with variable statistics (used/unused/unknown counts), detailed variable cards showing each variable's name, type, status, reference count, and usage detail, and a table of all variables with their statuses. Use the report to identify and remove unused state variables, reducing storage costs and improving contract efficiency.

TECHNICAL MECHANISM

The detector uses ethers.js v5.7.2 to perform a multi-stage state variable analysis. First, it calls eth_getCode to verify the contract is deployed and uses block explorer APIs (Etherscan, Sourcify) to fetch verified source code. The tool parses the source code to extract state variable declarations—including their names, types (uint, address, mapping, array, struct, etc.), and visibility (public, private, internal). It then analyzes the entire contract body to find references to each state variable, including reads (in expressions), writes (assignments), and uses in functions, modifiers, events, and other contexts. Each variable is classified: "used" if at least one reference is found, "unused" if no references are found, or "unknown" if the analysis cannot determine usage (e.g., due to complex patterns or external access). The tool also tracks which functions reference each variable, providing detailed evidence of usage. Results are compiled into a structured report with detailed variable information, usage evidence, and recommendations for removing unused state variables.

WHAT IT CANNOT SEE

This tool cannot detect unused state variables in contracts that are not verified or have opaque implementation details where source code is not available. It is limited by the availability and completeness of source code verification—if the source code is not fully verified or is obfuscated, the analysis may be incomplete. It cannot analyze variables that are accessed through external contract calls, delegate calls, or reflection-like patterns (e.g., using strings to reference variables). The analysis relies on the accuracy and completeness of source code parsing and reference analysis; syntax errors or non-standard patterns may produce inaccurate results. It cannot analyze contracts that are not deployed or have been self-destructed. The tool is limited to the specific contract instances and source code versions that are accessible via RPC and block explorer APIs. It cannot guarantee that detected unused variables reflect actual dead code without manual review—some variables may appear unused due to indirect references or external contract interactions that are not captured in the source code. State variables marked as "public" may be used by external contracts even if not referenced internally.

PLEASE NOTE

This is a read‑only analytics tool—it never submits transactions or modifies contract state. It is designed for EVM‑compatible chains and works best with verified contracts that have clean, parsable source code. The state variable analysis report is for informational and code quality purposes only and should not be considered a comprehensive code review. Always manually review detected unused variables before removing them, as some may be necessary for upgrade patterns, external interactions, or future functionality. The tool's classification is heuristic—variables marked as "unknown" may require manual inspection.

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.