referrerpolicy=no-referrer-when-downgrade

Attribute Macro frame_support::pallet_macros::inherent

source ·
#[inherent]
Expand description

The #[pallet::inherent] attribute allows the pallet to provide inherents.

An inherent is some piece of data that is inserted by a block authoring node at block creation time and can either be accepted or rejected by validators based on whether the data falls within an acceptable range.

The most common inherent is the timestamp that is inserted into every block. Since there is no way to validate timestamps, validators simply check that the timestamp reported by the block authoring node falls within an acceptable range.

Example usage:

#[frame_support::pallet]
mod pallet {
	// Example inherent identifier
	pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"timstap0";

	#[pallet::pallet]
	pub struct Pallet<T>(_);

	#[pallet::inherent]
	impl<T: Config> ProvideInherent for Pallet<T> {
		type Call = Call<T>;
		type Error = InherentError;
		const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;

		fn create_inherent(data: &InherentData) -> Option<Self::Call> {
			unimplemented!()
		}

		fn check_inherent(
			call: &Self::Call,
			data: &InherentData,
		) -> result::Result<(), Self::Error> {
			unimplemented!()
		}

		fn is_inherent(call: &Self::Call) -> bool {
			unimplemented!()
		}
	}
}

I.e. a trait implementation with bound T: Config, of trait ProvideInherent for type Pallet<T>, and some optional where clause.

§Macro expansion

The macro currently makes no use of this information, but it might use this information in the future to give information directly to construct_runtime.


Documentation for this macro can be found at frame_support::pallet_macros::inherent.