2

I am creating a new pallet, i have a simple task, get the current block author, i want to check whether I am the current one that is proposing the block or not by comparing the current block author with my id.

Unfortunately i have been looking and asking everywhere but there is no clear straightforward way of doing it in aura. it would be great if someone show me a step by step guide on how to solve this and how to properly think about solving such problems.

1
  • The current block author for the parachain or for the relay chain?
    – Bruno
    Oct 17, 2022 at 19:42

1 Answer 1

4

You can do so by implementing the pallet_authorship::EventHandler. pallet-collator-selection does exactly this, which is a pretty straightforward example.

Then, in the top level runtime, any pallet who's interested in receiving these events about block authorship has to be passed to the authorship pallet:

// in your pallet
impl<T: Config> pallet_authorship::EventHandler for Pallet<T> {..}

// in `runtime/lib.rs`
impl pallet_authorship::Config {
  type EventHandler: (PalletA, PalletB, ...)
  ..
}

Example.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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