kitchen/pallets/simple-event, kitchen/pallets/generic-event

In Substrate, transaction finality does not guarantee the execution of functions dependent on the given transaction. To verify that functions have executed successfully, emit an event at the bottom of the function body.

Events notify the off-chain world of successful state transitions

To declare an event, use the decl_event macro.

Simple Event

The simplest example of an event uses the following syntax

    pub enum Event {

The event is emitted at the bottom of the do_something function body:


Events with Generic Types

Sometimes events might contin types from the pallet's Configuration Trait. In this case, it is necessary to specify additional syntax

    pub enum Event<T> where AccountId = <T as system::Trait>::AccountId {
        EmitInput(AccountId, u32),

The syntax for deposit_event now takes the RawEvent type because it is generic over the pallet's configuration trait

Self::deposit_event(RawEvent::EmitInput(user, new_number));

See the next example to use the simple event syntax in the context of verifying successful execution of an adding machine