Skill 3.3.1
Use static analysis, fuzzing and audits to assess contract security
Key Concepts
Static analysis examines source code without running it. Slither detects patterns such as reentrancy, unchecked return values, tx.origin authorisation and shadowed variables in seconds, and Remix's static analysis plugin offers similar checks in the browser. Compiler warnings are a first, free layer.
Fuzzing calls functions with large numbers of generated inputs. Foundry and Hardhat Solidity tests treat any test function with parameters as a fuzz test, and tools such as Echidna run invariant tests that execute random sequences of calls and check that properties, such as "total supply equals the sum of balances", always hold. Symbolic execution tools such as Mythril reason about all possible inputs to find paths that reach unsafe states, and formal verification proves properties mathematically.
A security audit is an independent manual review by specialists, normally after the code is complete and tested. It is valuable but time-limited and does not guarantee the absence of bugs. After deployment, bug bounty programmes reward researchers for disclosing vulnerabilities, and monitoring detects suspicious transactions.