0x2::event
Events module. Defines the sui::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:
T
)T
)Example:
module my::marketplace {
use sui::event;
/* ... */
struct ItemPurchased has copy, drop {
item_id: ID, buyer: address
}
entry fun buy(/* .... */) {
/* ... */
event::emit(ItemPurchased { item_id: ..., buyer: .... })
}
}
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)