Self-Destruct Removal Migration Tool (Post-Cancun)
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
Self-Destruct Removal Migration Tool (Post-Cancun) analyzes smart contract bytecode and source code to detect SELFDESTRUCT opcode usage and recommend migration paths ahead of the Cancun Ethereum upgrade, which modifies SELFDESTRUCT behavior. It retrieves on-chain contract bytecode via eth_getCode and fetches verified source code and ABI from block explorer APIs. The tool performs opcode-level analysis to identify all instances of SELFDESTRUCT in the deployed bytecode, including indirect or obfuscated usages. It also analyzes storage slot usage patterns and state variable layouts to understand the context of each SELFDESTRUCT call—whether it's used for contract self-destruction, emergency shutdown, fund recovery, or migration flows. The output includes a migration status assessment, a count of SELFDESTRUCT occurrences, affected functions, estimated migration effort, and actionable recommendations for replacing SELFDESTRUCT with modern patterns such as balance transfer functions or withdrawal mechanisms. This enables developers to proactively migrate their contracts before the Cancun upgrade, preventing unexpected behavior or loss of functionality.
HOW TO USE
Connect your BGWallet to the target EVM chain. Paste the address of the contract you wish to analyze for SELFDESTRUCT usage. Optionally supply a GitHub repository URL to pull existing source code and migration patterns for additional context. The tool fetches the contract's bytecode, performs opcode disassembly and pattern matching, and analyzes storage usage to identify SELFDESTRUCT occurrences. Review the migration status, the list of detected usages with their severity, and the recommended migration steps. Use the analysis to guide your refactoring efforts, replacing SELFDESTRUCT with appropriate alternatives before the Cancun upgrade takes effect.
OPCODE DISASSEMBLY AND CONTEXTUAL ANALYSIS ENGINE
The real technical mechanism is the opcode disassembly and contextual analysis engine that combines bytecode scanning with storage impact assessment. The tool first disassembles the entire deployed bytecode into its constituent opcodes, then scans for the SELFDESTRUCT opcode (0xFF) across the entire codebase. For each occurrence, it traces backward through the disassembled code to identify the function or code path that contains it, using control flow analysis to map opcode sequences to function boundaries. The tool also analyzes storage slot usage patterns to understand the context: if SELFDESTRUCT appears in code that zeroes out storage slots before destruction, it's likely a gas token pattern; if it appears in a function with access control modifiers, it's likely an emergency shutdown mechanism; if it appears in migration logic, it may be part of a contract upgrade flow. The engine then computes a risk score for each occurrence based on the likelihood of execution, the severity of impact if removed, and the complexity of migration. The final output includes a weighted migration effort estimate, with simple cases (single SELFDESTRUCT in a kill function) rated low effort and complex cases (multiple occurrences across business logic) rated high effort. This approach provides developers with a clear, prioritized migration plan that addresses the most critical SELFDESTRUCT usages first.
WHAT IT CANNOT SEE
This tool cannot detect all SELFDESTRUCT usages without access to contract bytecode or source code. It is limited by your RPC provider's rate limits for bytecode retrieval, which may delay analysis on congested networks. It cannot determine if SELFDESTRUCT is actually executed at runtime versus merely present in bytecode—some occurrences may be in unreachable code paths that never execute. The detection relies on the completeness of the ABI and source code verification; unverified contracts or incomplete verification data will produce incomplete or inaccurate results. Detection is based on bytecode pattern matching and may miss obfuscated or indirect usages, such as SELFDESTRUCT called via DELEGATECALL or through inline assembly that obscures the opcode. The tool cannot assess the full impact of SELFDESTRUCT removal on contract logic without execution context—some contracts may rely on SELFDESTRUCT for fund recovery or contract lifecycle management in ways that are not obvious from static analysis. It may produce false positives for contracts that have SELFDESTRUCT in unreachable code paths, flagging them as requiring migration when they don't. The tool does not execute the contract to validate migration recommendations, so it cannot confirm that proposed replacements maintain the same behavior. It cannot account for network-specific timing or EIP activation schedules, which may vary across different EVM-compatible chains.
PLEASE NOTE
This tool works exclusively with EVM-compatible chains. It requires active internet connectivity to access block explorer APIs and RPC endpoints. Some block explorers may require API keys for high-volume bytecode retrieval. The tool is read-only and does not modify or deploy any code—it only produces analysis and recommendations. The Cancun upgrade modifies SELFDESTRUCT behavior; contracts that rely on it may break. Always test migration changes thoroughly on testnet before mainnet deployment.