Skip to main content

Module 0x2::event

Events module. Defines the iota::event::emit function which creates and sends a custom MoveEvent as a part of the effects certificate of the transaction.

Every MoveEvent has the following properties:

  • sender
  • type signature (T)
  • event data (the value of T)
  • timestamp (local to a node)
  • transaction digest

Example:

module my::marketplace {
use iota::event;
/* ... */
struct ItemPurchased has copy, drop {
item_id: ID, buyer: address
}
entry fun buy(/* .... */) {
/* ... */
event::emit(ItemPurchased { item_id: ..., buyer: .... })
}
}

Function emit

Emit a custom Move event, sending the data offchain.

Used for creating custom indexes and tracking onchain activity in a way that suits a specific application the most.

The type T is the main way to index the event, and can contain phantom parameters, eg emit(MyEvent<phantom T>).

public fun emit<T: copy, drop>(event: T)

Implementation

public native fun emit<T: copy + drop>(event: T);