Skip to main content

LogEvent

Function LogEvent 

Source
pub fn LogEvent(
    topic0: Option<&[u8; 32]>,
    topic1: Option<&[u8; 32]>,
    topic2: Option<&[u8; 32]>,
    data: &[u8],
) -> Result<(), SysErr>
Expand description

Logs an event with up to 3 topics and additional data. Constructs a TxEmittedEvent where the serialized_event field contains the topics prepended to the data: topic0 || topic1 || topic2 || data. The num_topics field indicates how many leading 32-byte chunks are topics, enabling downstream indexers to efficiently filter events. Events are stored in the transaction’s event log and accumulated into a per-block merkle-patricia trie.

§Arguments

  • topic0
  • topic1
  • topic2
  • data

This is a convenience wrapper around uninit_LogEvent that returns the result as SyscallResult<T>.

§Errors

  • kSyscallErrorCodeInvalidSyscallInput: The serialized event (32 bytes per supplied topic plus the data) is longer than kMaxEventLength, the transaction has already emitted kMaxEventsPerTransaction events, or topics are not supplied in a continuous sequence (e.g., topic0 and topic2 provided without topic1).