1

I want to understand this code.

pub trait Trait: balances::Trait {
    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}

Could you please explain in detail one word code at a time?

pub trait Trait means, define trait named Trait?

balances::Trait what's this? Is this for Trait?

type Event: ?

From<Event<Self>> ....?

+ Into<<Self as system::Trait>::Event> ....?

1

1 Answer 1

1

You're defining a trait called Trait, which will idiomatically be referred to in other places as your_pallet_name::Trait.

It descends from balances::Trait, which means that this functionality is dependent on the balances functionality and can make use of it.

The Event type would be fulfilled by the actual top-level Event type when the runtime is put together (and your pallet is combined with other pallets to produce an event type that encompasses events from all the pallets together). The bounds indicate that it's convertible From the local events declared by your pallet, and that it's convertible Into the low-level event type that actually gets placed in the event storage at the end of the block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.