The Smart Contract Flattener tool- that melts imports, solders your contracts & forges a single fused
.soloutput.
SolderX is a developer-first, all-in-one Solidity flattener that handles files, folders, and verified contracts from various Explorersโ all on-the-fly. It features robust import resolutions, advanced remapping support, SPDX unification, topological sorting, import deduplication & cyclic dependency detection.
๐ Built for researchers, auditors, solidity developers who need to flatten Solidity smart contracts for Etherscan (re)verification, security audits, or integrations with tools like Slither, Mythril, Foundry and Remix IDE. SolderX, thus ensures your flattened solidity output is clean and analysis-ready.
pip install solderxSolderX is now available on PyPI โ install it in seconds and start soldering Solidity contracts effortlessly.
โ Requirements: Python 3.8+
SolderX takes care of everything:
- โ Flatten a single file, entire project folder, or verified solidity contracts from explorers (like Etherscan)
- โ Supports remappings, relative imports, and handles complex cyclic dependencies
- โ
Fully in-memory parsing โ no
.solclutter or manual cleanup from explorer downloads
One powerful CLI + Python tool โ clean, audit-ready output in seconds.
Most flatteners break on remappings, folder imports, or explorer parsings โ SolderX doesn't.
| ๐ง Feature | ๐ง Description | โ Status |
|---|---|---|
| ๐ฉ Flatten Everything | Flatten from single files, full folders, or on-chain verified contracts | โ |
| ๐ง Smart Import Resolver | Handles nested imports, multiline/same-line cases, and deduplicates cleanly | โ |
| ๐ฆ Scan from Explorers | Supports Etherscan, Polygonscan, BscScan, Arbiscan, Base, Optimism, Avalanche | โ |
| ๐ In-Memory Flattening | No temp or unflattened junk files saved โ All flattening done in-memory | โ |
| ๐ช Remapping Support | Supports & resolves robust remappings (basic, deep, longest-match) | โ (file) |
| ๐งญ Relative Imports in Remappings | Resolves ./ and ../ paths even within remapped libraries |
โ (file) |
| ๐ Import Parsing Engine | Extracts imports safely โ ignores inside comments and strings | โ |
| ๐งฑ Cyclic Import Detection | Flags and breaks infinite loops in import trees | โ |
| ๐ Folder-Aware Flattening | Detects and blocks out-of-scope imports across folder boundaries | โ |
| ๐ Chain + Address Validation | Catches malformed contract addresses and unsupported chains | โ |
| ๐ SPDX Header Merging | Deduplicates and merges license headers cleanly | โ |
| ๐งฑ Import Deduplication | Ensures each dependency is flattened only once | โ |
| ๐งฐ Python API Support | Expose all core functions (file, folder, scan) via clean Python API |
โ |
| ๐ป Themed CLI Interface | Minimal, expressive CLI with emoji-based output and colored logs | โ |
| โก Fast & Lightweight | Built with Python, no heavy dependencies | โ |
| ๐ Static Analysis Ready | Output works with all static analyzers | โ |
| ๐ง Pluggable Design | Designed to extend โ GitHub flattening, config aliasing, IDE plugins | ๐ง Planned |
โ ๏ธ Note: This comparison is a working draft. Feature support for third-party tools may be evolving, and accuracy is based on current public documentation and observed behavior. Final evaluation pending deeper testing.
| Feature | SolderX | Hardhat / Foundry / Remix | poa/solidity-flattener | solidity-flattener | truffle-flattener | sol-merger | slither-flatten |
|---|---|---|---|---|---|---|---|
| ๐งฉ Standalone file flattening | โ | โ | โ | โ | โ | โ | โ |
| ๐ Folder/project flattening | โ | โ | โ | โ | โ | ||
| ๐ Etherscan flattening (verified source) | โ | โ | โ | โ | โ | โ | โ |
| โก On-the-fly (no temp files saved) | โ | โ | โ | โ | โ | โ | โ |
๐ Smart remapping resolution (@...) |
โ Deep | โ | โ | โ | โ Basic | โ | |
| ๐ Relative imports in remapped libs | โ | โ | โ | โ | โ | โ | โ |
| ๐งช Multiline & nested import handling | โ | โ | โ | โ | โ | โ | |
| โป๏ธ Cyclic import detection & handling | โ | โ | โ | โ | โ | โ | โ |
| ๐งน SPDX / license metadata cleanup | โ | โ | โ | โ | โ | โ | โ |
| ๐งฌ Deduplicated output | โ | โ | โ | โ | โ | โ | |
| ๐ง Comment-aware import extraction | โ | โ | โ | โ | โ | โ | โ |
| ๐ Python API support | โ | โ | โ | โ | โ | โ | โ |
| ๐ป CLI with themed logs | โ | โ | โ | โ Basic | โ | ||
| ๐ Slither-compatible output | โ | โ | โ | ||||
| ๐ซ Chain/address validation (Etherscan) | โ | โ | โ | โ | โ | โ | โ |
| ๐ง Future-ready: GitHub flattening, aliases | โ Planned | โ | โ | โ | โ | โ | |
| ๐ง Maintained actively | โ | โ | โ | โ | โ | โ |
โก๏ธ SolderX is the only tool that combines all flattening modes into a single interface โ file, folder, or Etherscan โ and handles real-world Solidity quirks out of the box.
pip install solderx# Simple file
solderx MyContract.sol
# Simple file with output path
solderx MyContract.sol --output MyContract_Flat.sol
# With remappings
solderx path/to/Contract.sol -r remappings.json# Project folder with inline remapping
solderx src/ --remappings "@a=lib/a,@b=node_modules/b"
# With a remappings json
solderx project/contracts --remappings remappings.json
# With remappings and output filepath
solderx path/to/project/ -r remappings.json -o flattened/soldered_project.sol# fetch from etherscan
solderx 0xAbC...123 -chain eth --api-key YOUR_API_KEY
# also fetch from etherscan
solderx eth:0xAbC...123 --api-key YOUR_API_KEY
from solderx import solder_file, solder_folder, solder_scan
# ๐น 1. Flatten a single file
flattened_code = solder_file("path/to/Contract.sol")
# With remappings
flattened_code = solder_file("path/to/Contract.sol", remappings={"@oz": "lib/openzeppelin-contracts"})
# ๐น 2. Flatten an entire folder
flattened_code = solderx("contracts/")
# With remappings
flattened_code = solder_file("path/to/Contract.sol", remappings={"@oz": "lib/openzeppelin-contracts"})
# ๐น 3. Flatten from verified explorer source
# Flatten from Etherscan
flattened_code = solderx("0x123..789", chain = 'eth')
flattened_code = solderx("eth:0x123..789")
# ๐น save file (default = False)
_ = solder_file("path/to/Contract.sol", save_file=True)
# save file in specified path
_ = solder_file("path/to/Contract.sol", output_path='./Contract_Flat.sol')- ๐ ๏ธ Aliasing via config file (
solderx.toml) - ๐
Githubrepo flattening - ๐งน Strip all comments (inline, block, NatSpec - toggleable)
- ๐ Flatten by contract name (regex filtering)
- ๐ Color logs and interactive CLI summaries
- ๐งช
solcoutput validation (AST / compile test) - ๐ Plugin support:
slither,mythril,sourcify
Pull requests are welcome!
If youโve found a bug, a confusing case, or have feature ideas โ open an issue or discussion on the repo.
Weโre building this tool for Solidity developers like you.
- ๐ Re-verify contracts on Etherscan after audits or refactors
- ๐ก๏ธ Feed single files into static analyzers like Slither, Mythril, Semgrep
- ๐งฉ Compare bytecode outputs between flattened and deployed versions
- ๐ Onboard contributors by flattening large repos for easier reading
- ๐งฐ Pipeline-ready for CI/CD, security scans, or deployment packaging
| Category | solder_file() |
solder_folder() |
solder_scan() |
|---|---|---|---|
| Flat imports | โ | โ | โ |
| Nested imports | โ | โ | โ |
| Save Flat File | โ | โ | โ |
| Multiline imports | โ | โ | โ |
| Multiple imports on same line | โ | โ | โ |
| Missing import (in-scope) | โ | โ | โ |
| Missing import (out-of-scope) | N/A | โ | โ |
| Import outside folder scope detection | N/A | โ | โ |
| Cyclic imports | โ | โ | โ |
| Remapping (basic + deep + longest) | โ โ โ | ๐ง N/A | ๐ง N/A |
| SPDX header merging | โ | โ | โ |
| Import deduplication | โ | โ | โ |
| Handle empty files | โ | โ | โ |
| Relative imports in remapped libs | โ | ๐ง N/A | ๐ง N/A |
| Relative import resolution | โ | โ | โ |
| Flattened & multi-file JSON parsing | N/A | N/A | โ |
| Contract name parsing | N/A | N/A | โ |
| Chain support handling | N/A | N/A | โ |
| Invalid address handling | N/A | N/A | โ |
All core behaviors are verified using Pytest.
Want more scenarios covered? Open an issue
SolderX is released under the MIT License
ยฉ 2025 โ Crafted with โค๏ธ for developers and researchers seeking reliable, complete tooling.
Commercial use is allowed provided that:
- You include SolderX as a dependency (
pip install solderx), OR - You give visible credit, e.g., โFlattened using SolderXโ in your tool, docs, or repo.
Please donโt rebrand or redistribute without attribution โ letโs build openly and respectfully ๐ค
Weโre just getting started โ expect support for more chains, deeper integrations, and smart dev-first features soon.
๐ Track progress, report issues, or request enhancements on the GitHub repo.
Letโs forge ahead with SolderX โ and make Solidity flattening reliable, intuitive, and developer-friendly.