Runtime Events
How to tell someone using your blockchain something happened.
Last updated
Was this helpful?
How to tell someone using your blockchain something happened.
Last updated
Was this helpful?
Users of the application need feedback about what happened when they clicked something or interacted on your chain through a you've given them.
Transactions can fail for any number of reasons, so your users need to know and that is handled through and Event
. Confirmations are similar: tell your user it went okay with an Event
.
Yep, pretty much without exception. Here's how:
Add Event
type to the `Config:
And now add the decl_module!
("declare_module") macro to give access to the deposit_event()
method.
decl_event!
("declare event") macro is the way Rust implements an event
We are showing generic types in these examples. The syntax for generic events requires the where
.
We've defined a trait
in the Pallet
for Config
and so now it has to be implemented at runtime.
In your runtime lib.rs
file, add
The code above is simply specifying the type for Event
. Note the <T>
is not shown and that is because we are defining the concrete type to be implemented by the Pallet
we're configuring.
Add the events to the runtime build macro construct_runtime!
by adding: