Events

Syntax
Event :
   event IDENTIFIER : NEWLINE
   INDENT
   EventField*
   DEDENT

EventField :
   EventIndexability IDENTIFIER : Type

EventIndexability :
   idx?

An event is a nominal event type defined with the keyword event. It is emitted with the keyword emit.

An example of a event item and its use:

use std::context::Context

contract Foo:
    event Transfer:
        idx sender: address
        idx receiver: address
        value: u256

    fn transfer(ctx: Context, to: address, value: u256):
        # Heavy logic here
        # All done, log the event for listeners
        emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value)