Skip to main content

Event

Derive Macro Event 

Source
#[derive(Event)]
{
    // Attributes available to this derive:
    #[event]
    #[topic]
}
Expand description

Derives the Event trait for structured logging.

§Attributes

  • #[event(name = "EventName")] - Sets the event name
  • #[event(anonymous)] - Creates an anonymous event (no signature topic)
  • #[topic] - Marks a field as indexed
  • #[event(skip)] - Excludes a field from the event

§Example

#[derive(Event)]
#[event(name = "Transfer")]
struct Transfer {
    #[topic]
    from: [u8; 32],
    #[topic]
    to: [u8; 32],
    amount: u128,
}