#[event]
Expand description
Implements the necessary traits for a struct
to be emitted as an event from a
contract.
By default, a signature topic will be generated for the event. This allows consumers
to filter and identify events of this type. Marking an event with anonymous = true
means no signature topic will be generated or emitted.
Custom signature topic can be specified with signature_topic = <32 byte hex string>
.
signature_topic
and anonymous
are conflicting arguments.
§Examples
#[ink::event]
pub struct MyEvent {
pub field: u32,
#[ink(topic)]
pub topic: [u8; 32],
}
// Setting `anonymous = true` means no signature topic will be emitted for the event.
#[ink::event(anonymous = true)]
pub struct MyAnonEvent {
pub field: u32,
#[ink(topic)]
pub topic: [u8; 32],
}
// Setting `signature_topic = <hex_string>` specifies custom signature topic.
#[ink::event(
signature_topic = "1111111111111111111111111111111111111111111111111111111111111111"
)]
pub struct MyCustomSignatureEvent {
pub field: u32,
#[ink(topic)]
pub topic: [u8; 32],
}