Events write to the transaction log, which contracts cannot read but indexers, wallets and front-ends can. Up to three parameters may be `indexed`, becoming searchable topics.
event Staked(address indexed user, uint256 amount);
function stake(uint256 amount) external {
bal[msg.sender] += amount;
emit Staked(msg.sender, amount);
}Logs are much cheaper than storage, so emit an event for every state change you would want to reconstruct later.