Missing Events Remediation
Overview
Related Detector: Missing Events
Events are how the outside world sees on-chain state change. Ownership transfers, role grants, parameter updates, and pause toggles that mutate state without emitting an event are invisible to explorers, indexers, and monitoring — an incident can unfold with no alert. The remediation is to emit a well-typed event on every privileged mutation.
Recommended Fix
Before (Vulnerable)
function setFee(uint256 newFee) external onlyOwner {
fee = newFee; // silent — no monitor can see the change
}
After (Fixed)
event FeeUpdated(uint256 oldFee, uint256 newFee);
function setFee(uint256 newFee) external onlyOwner {
emit FeeUpdated(fee, newFee); // emit before or after; include old and new
fee = newFee;
}
Index the fields monitors will filter on (addresses, ids) with indexed, and include both the old and new value so a consumer can reconstruct the transition without an archive node.
Common Mistakes
- Emitting an event for user actions but not for admin actions, which are the ones defenders most need to watch.
- Logging only the new value, forcing consumers to diff against prior state to know what changed.
- Marking more than three parameters
indexed(the EVM allows at most three topics beyond the signature).