Event
A logging mechanism that records important contract actions on the blockchain for external monitoring.
Last Updated
2026-03-19
Related Concepts
What is Event?
In smart contract development (specifically Solidity), an event is a language construct used to output data to the blockchain's logging facility. It allows developers to "broadcast" that something significant has happened within their code.
How does Event work?
- A developer defines an event signature at the top of their contract (e.g., event Transfer(address indexed from, address indexed to, uint value)).
- Inside a function, the developer uses the emit keyword to trigger the event.
- Up to three parameters can be marked as indexed, which allows external tools to filter for specific values (like a specific address).
- Once emitted, the event data is stored in the transaction's logs and cannot be accessed by smart contracts themselves.
- External "listeners" (using libraries like ethers.js) detect these emissions and trigger off-chain actions.
Why does Event matter?
Events are the "output" mechanism for decentralized applications. They enable the creation of responsive user interfaces and efficient data indexing.
Key features of Event
- Defined in Solidity via the event keyword
- Triggered using the emit statement
- Supports up to 3 indexed parameters for filtering
- Inaccessible to smart contracts (one-way communication)
- Highly efficient for off-chain data retrieval
Examples of Event
The most common example is the Transfer event in the ERC-20 standard. Every time tokens move, this event is emitted, allowing wallets like MetaMask to "see" the incoming tokens and update your balance display instantly.
