referrerpolicy=no-referrer-when-downgrade

Attribute Macro frame_support::pallet_macros::weight

source ·
#[weight]
Expand description

Allows specifying the weight of a call.

Each dispatchable needs to define a weight with the #[pallet::weight($expr)] attribute. The first argument must be origin: OriginFor<T>.

§Example

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

	#[pallet::call]
	impl<T: Config> Pallet<T> {
		#[pallet::weight({0})] // <- set actual weight here
		#[pallet::call_index(0)]
		pub fn something(
			_: OriginFor<T>,
			foo: u32,
		) -> DispatchResult {
			unimplemented!()
		}
	}
}

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