Expand description
Event logging system for smart contracts.
This module provides traits and utilities for emitting structured events from smart contracts. Events are indexed logs that can be queried off-chain.
§Example
ⓘ
use truthlinked_sdk::prelude::*;
#[derive(Event)]
#[event(name = "Transfer")]
struct Transfer {
#[topic]
from: [u8; 32],
#[topic]
to: [u8; 32],
amount: u128,
}
fn transfer(from: [u8; 32], to: [u8; 32], amount: u128) -> Result<()> {
Transfer { from, to, amount }.emit()?;
Ok(())
}Modules§
- __
private - Private re-exports for macro-generated code.
Traits§
- Event
- Trait for event types that can be emitted.
- Event
Data - Trait for types that can be encoded as event data.
- Event
Topic - Trait for types that can be converted to event topics.
Functions§
- decode_
event_ data - Decodes event data into a typed value.
- emit
- Emits a log event with the given topics and data.
- emit_
event - Emits an event implementing the
Eventtrait. - event_
signature - Computes the event signature hash for a given event name.
- event_
topics_ match - Checks if the given topics match the event signature.
- indexed_
topics - Returns the indexed topics (excluding the signature topic).
- topic_
from_ bytes - Converts raw bytes to a 32-byte topic (left-padded with zeros if shorter).