# Slither — Static Analysis Framework for Solidity Smart Contracts > A Python-based static analysis tool for Solidity that detects vulnerabilities, suggests optimizations, and surfaces code quality issues in Ethereum smart contracts. ## Install Save as a script file and run: # Slither — Static Analysis Framework for Solidity Smart Contracts ## Quick Use ```bash pip install slither-analyzer # Analyze a Solidity project slither . # Analyze a single file slither MyContract.sol ``` ## Introduction Slither is a static analysis framework for Solidity smart contracts, developed by Trail of Bits. It runs a suite of vulnerability detectors, code quality checks, and gas optimization suggestions against Solidity source code without executing it. Slither is widely used in the Ethereum security community for auditing contracts before deployment. ## What Slither Does - Detects over 90 classes of vulnerabilities including reentrancy, uninitialized storage, and integer overflow - Analyzes inheritance graphs, function visibility, and state variable access patterns - Suggests gas optimizations like packing storage variables and removing dead code - Prints contract summaries, function call graphs, and inheritance diagrams for manual review - Supports custom detectors and printers via a Python plugin API ## Architecture Overview Slither parses Solidity source through the solc compiler to obtain an AST, then builds its own intermediate representation called SlithIR. SlithIR converts Solidity into a reduced instruction set (similar to SSA form) that enables precise dataflow analysis. Detectors run over SlithIR to identify vulnerability patterns, while printers generate human-readable summaries and visualizations of contract structure. ## Self-Hosting & Configuration - Install from PyPI: `pip install slither-analyzer` - Requires a compatible solc compiler version installed (solc-select helps manage versions) - Run `slither .` in a Hardhat, Foundry, or Truffle project root to analyze all contracts - Configure which detectors to enable or exclude via command-line flags or a slither.config.json file - Integrate into CI by checking the exit code: non-zero means findings above the configured severity threshold ## Key Features - 90+ built-in vulnerability detectors covering the OWASP Smart Contract Top 10 - SlithIR intermediate representation enabling precise taint analysis and dataflow tracking - Support for Hardhat, Foundry, Truffle, and Dapp project structures out of the box - Printers for call graphs, inheritance trees, variable ordering, and contract summaries - Custom detector and printer API for writing organization-specific security rules ## Comparison with Similar Tools - **Mythril** — uses symbolic execution and SMT solving for deeper path exploration; Slither is faster and catches more surface-level patterns - **Securify2** — pattern-based analysis for Solidity; Slither has more detectors and active maintenance - **Echidna** — property-based fuzzer for Solidity; complements Slither by testing runtime behavior rather than static patterns - **Foundry forge test** — tests contract logic but does not perform security-focused static analysis - **Aderyn** — Rust-based Solidity analyzer; newer with fewer detectors than Slither's mature suite ## FAQ **Q: Does Slither find all smart contract vulnerabilities?** A: No static analyzer can guarantee complete coverage. Slither catches common vulnerability patterns but should be part of a broader audit that includes manual review and fuzzing. **Q: Can I use Slither with Foundry projects?** A: Yes. Slither detects Foundry projects automatically and compiles via forge build before analysis. **Q: How do I suppress false positives?** A: Use `// slither-disable-next-line detector-name` comments in the source or exclude detectors via `--exclude` flags. **Q: Does Slither support Vyper contracts?** A: No. Slither is designed specifically for Solidity. For Vyper, consider dedicated tools like VyperLang's built-in compiler warnings. ## Sources - https://github.com/crytic/slither - https://blog.trailofbits.com/2018/10/19/slither-a-solidity-static-analysis-framework/ --- Source: https://tokrepo.com/en/workflows/asset-c8323e0e Author: Script Depot