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

Source Code Flattening Tool for Verification

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

Source Code Flattening Tool for Verification is a developer-focused utility that consolidates Solidity source code and its imported dependencies into a single, flattened file suitable for contract verification on block explorers. It takes a main Solidity source file and optional additional dependency files from the user, parses import directives, and replaces them with the actual dependency source code. The tool preserves the main file's pragma statement at the top, removes duplicate import directives from dependencies, and outputs a single contiguous file with all contracts and libraries included. It also identifies unresolved imports, warns the user about missing dependencies, and provides a copy-and-download interface for the flattened output. This streamlines the verification process for contracts with complex dependency trees that would otherwise require manual consolidation or external flattening tools.

HOW TO USE

Paste the main Solidity source file into the "Main Solidity source file" text area. This should be the contract you want to verify. Optionally, paste additional dependency source files into the "Additional source files" text area, separating each file with "=== filename.sol ===" on its own line. For example: "=== MyLibrary.sol ===\npragma solidity ^0.8.0;\nlibrary MyLibrary { ... }". Click "Flatten source" to process the files. The tool will display a summary including the number of imports found, dependencies provided, flattened lines, and any unresolved import warnings. The flattened source code is displayed in a scrollable output area with copy and download buttons.

TECHNICAL NOTE: IMPORT RESOLUTION AND DUPLICATE HANDLING

The tool implements a multi-pass flattening algorithm that first parses all import directives from the main source using regex matching for import statements. It then processes each dependency file, removing its own import statements to avoid duplication. The tool injects each dependency after the main contract body or at the end of the file, with a comment marker indicating the original filename. Pragmas from dependencies are stripped to avoid multiple pragma directives, while the main file's pragma is preserved at the top. The tool also tracks unresolved imports and reports them as warnings, allowing developers to identify missing dependencies. The output is normalized by removing excess blank lines and preserving the original source structure as much as possible.

WHAT IT CANNOT SEE

The tool cannot automatically resolve external imports from npm packages or GitHub repositories without the user providing the actual source files. It cannot handle import paths that are absolute or use non-standard resolvers (e.g., hardhat or truffle aliases). It cannot compile or validate the flattened code; it only performs textual replacement. It cannot detect circular dependencies between files, which would cause infinite recursion. It cannot flatten non-Solidity files such as JSON or JavaScript. The tool is limited by browser memory for large codebases, which may cause performance issues or crashes. It cannot resolve imports from private repositories that require authentication. It cannot handle Solidity versions with incompatible syntax changes across different pragma ranges.

PLEASE NOTE

This tool is designed exclusively for Solidity source code used on EVM-compatible chains. It does not support other smart contract languages like Vyper or Rust. The flattening process is purely textual and does not include compiler metadata; the user is responsible for providing all dependencies accurately. The tool does not connect to any external API or RPC; all processing is done client-side. Always verify that the flattened source code compiles with the expected compiler version before submitting to a block explorer. The tool provides no warranty that the flattened code will be accepted by all explorers; users should verify the output manually.

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.