Echidna is a property-based fuzzer for Ethereum smart contracts, built by Trail of Bits. Instead of checking specific inputs the way unit tests do, it generates thousands of random transaction sequences trying to break the invariants you declare. This guide covers installation, writing properties and assertions, configuring campaigns and turning a failure into a high-quality audit finding.

Why fuzz smart contracts?
Unit tests confirm that known inputs produce expected outputs. Fuzzing asks a different question: is there any sequence of calls that violates a rule that should always hold? For contracts holding value, “always” properties — total supply never exceeds the cap, the sum of balances equals total supply, a user can never withdraw more than they deposited — are exactly what an attacker tries to break.
Installation
# Precompiled binary (Linux/macOS): download from the GitHub releases page,
# or install with the Trail of Bits toolchain
pip install crytic-compile slither-analyzer
# Docker is the simplest reproducible option
docker pull ghcr.io/crytic/echidna/echidna
echidna --version
Echidna compiles your project with crytic-compile, so it understands Foundry, Hardhat and solc layouts automatically.
Writing properties
A property is a public or external function named with your chosen prefix (default echidna_) that returns a boolean. Echidna tries to make it return false.
// Token.property.sol
import "./Token.sol";
contract TokenTest is Token {
address echidna_caller = msg.sender;
// Property: no account can ever hold more than the total supply.
function echidna_balance_under_supply() public view returns (bool) {
return balanceOf(echidna_caller) <= totalSupply();
}
// Property: total supply never exceeds the hard cap.
function echidna_supply_capped() public view returns (bool) {
return totalSupply() <= CAP;
}
}
echidna Token.property.sol --contract TokenTest
If Echidna finds a call sequence where a property returns false, it prints the shrunken sequence — the minimal set of calls that triggers the failure.
Assertion mode
Assertion mode checks assert() statements inside your functions, which is convenient for invariants that depend on function arguments.
function transfer(address to, uint256 amount) public override {
uint256 before = balanceOf(msg.sender) + balanceOf(to);
super.transfer(to, amount);
// The combined balance of two parties must not change on transfer.
assert(balanceOf(msg.sender) + balanceOf(to) == before);
}
echidna Token.sol --contract Token --test-mode assertion
Configuring a campaign
A YAML config keeps runs reproducible.
# echidna.yaml
testMode: assertion
testLimit: 100000 # number of transactions to try
seqLen: 50 # max calls per sequence
shrinkLimit: 5000 # effort spent minimising a failing case
corpusDir: corpus # save/replay the corpus between runs
coverage: true
sender: ["0x10000", "0x20000", "0x30000"]
echidna Token.sol --contract Token --config echidna.yaml
Saving a corpusDir lets later runs continue from the coverage already reached, which is what makes long overnight campaigns worthwhile.
From a failure to an audit finding
When Echidna breaks a property it gives you a concrete, reproducible sequence. A good finding writes that up clearly:
- State the invariant that was violated and why it matters.
- Include the shrunken sequence Echidna produced as the proof of concept.
- Explain the root cause in the contract logic — rounding, missing check, reentrancy.
- Recommend a fix and, ideally, add the property to the project’s test suite so it never regresses.
Echidna and Foundry fuzzing complement each other. Foundry’s invariant tests live next to unit tests and run fast in CI; Echidna’s coverage-guided campaigns with corpus management often reach deeper states. Many auditors express the same invariants in both. See our Foundry guide.
Key takeaways
- Fuzzing finds call sequences that break invariants you declare — not just known inputs.
- Property mode checks boolean functions; assertion mode checks
assert()inside your code. - Save a corpus and run long campaigns before a report or release.
- Every failure ships with a shrunken, reproducible proof of concept — perfect for the report.
Frequently asked questions
What is Echidna?
Echidna is an open-source, property-based fuzzer for Ethereum smart contracts developed by Trail of Bits. It generates sequences of transactions trying to falsify user-defined properties or assertions.
Echidna or Foundry fuzzing — which should I use?
Both. Foundry’s fuzz and invariant tests are fast and live next to unit tests; Echidna offers grammar-aware, coverage-guided campaigns, corpus management and shrinking that often reach deeper states. Many auditors run the same invariants in both.
How long should a fuzzing campaign run?
Start with minutes during development, then run long campaigns (hours to days) before an audit report or a release, saving the corpus so later runs continue from the coverage already reached.
