Contracts that hold up when the money is real.
A contract is the one thing you can't patch after it ships. So we write it to be read: clean, tested to the edges, static-analyzed, and audit-ready before a cent goes near it.
Green tests are the floor. The real work is the code being readable enough that a reviewer can trust it, and hard enough that the fuzzer can't break it.
Watch an attacker try to drain the vault.
The classic exploit: a malicious contract re-enters withdraw before the balance updates. Turn the guard off and watch the vault empty. Turn it on and the same attack reverts.
Checks-effects-interactions plus a nonReentrant guard. The balance is zeroed before the external call, so the re-entry finds nothing to take.
Written to be read.
Most exploits live in code the author found clever. We don't write clever. A reviewer should be able to read a function top to bottom and know it's safe.
1error InsufficientBalance();23contract Vault {4 mapping(address => uint256) public balanceOf;5 bool private locked;67 event Withdrawn(address indexed user, uint256 amount);89 modifier nonReentrant() {10 require(!locked, "reentrant"); // ← the guard11 locked = true;12 _;13 locked = false;14 }1516 function withdraw(uint256 amount) external nonReentrant {17 if (balanceOf[msg.sender] < amount) revert InsufficientBalance();1819 balanceOf[msg.sender] -= amount; // effects first20 emit Withdrawn(msg.sender, amount);2122 (bool ok, ) = msg.sender.call{value: amount}(""); // interaction last23 require(ok, "transfer failed");24 }25}The balance is updated before the external call, so a callback can't drain the vault twice.
nonReentrant locks the function for the duration of the call. Belt and braces.
Cheaper than revert strings, and the reason is a type, not a guess.
So the indexer and the user can both follow what happened.
Tested like it holds money, handed over clean.
We write the properties that must always hold and let the fuzzer attack them, then hand the auditor a documented, analyzed, threat-modeled contract, not a pile of surprises.
Contracts that hold up when the money is real.
Written to be read, tested to the edges, static-analyzed, and audit-ready before a cent goes near it. The one thing you can't patch, done right the first time.