Skip to main content

Module log

Module log 

Source
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.
EventData
Trait for types that can be encoded as event data.
EventTopic
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 Event trait.
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).