Events (Smart Contract Logging)
1 min read
Pronunciation
[ee-vents smart kon-trakt log-ing]
Analogy
Events are like headlines in a newspaper—they summarize important occurrences for readers (off‑chain listeners) without storing them in the main story.
Definition
EVM logs emitted by contracts to record indexed data and facilitate efficient off‑chain monitoring and filtering.
Key Points Intro
Events enhance transparency via:
Key Points
Indexed topics: Up to 3 indexed parameters for efficient filtering.
Data field: Stores non‑indexed event arguments.
Gas efficiency: Cheaper than storage writes for audit trails.
Off‑chain listeners: Tools like The Graph subscribe to events.
Example
```
event Transfer(address indexed from, address indexed to, uint256 value);
function transfer(...) { ...; emit Transfer(msg.sender, to, amt); }
```
Technical Deep Dive
Security Warning
Relying solely on events for critical state can be unsafe—events are not accessible to contracts and may be pruned in archive nodes.
Caveat
Events are not accessible on‑chain; do not use them for contract logic decisions.
Events (Smart Contract Logging) - Related Articles
No related articles for this term.