starknet::Event
traitEvent
enum in the contract, annotated with #[event]
, where each variant is linked to an event structemit
function#[key]
attribute to specific fields, which indexes them for efficient querying later.
Events variant names and structs are recommended to be named consistently, even if it create some redundancy when emitting events.
Here’s a practical example of a contract that emits events when incrementing a counter:
Event
enum.