While configuring any pallet (treasury pallet in my case), we need to configure some required associative types. To set the values of these required types, we mostly define some constants within the parameter_types!() macro.

I will quote here the example of pallet_treasury configuration in Kusama here.

In the given example, a constant is defined to be used for PalletId required associative type like this:

pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");

Now my question is, can we refer to that constant anywhere else in our runtime code? if Yes how?

2 Answers 2


parameter_types will implement the Get for you.


fn example() {
    let treasury_pallet_id = TreasuryPalletId::get();

In the code you have the config of the pallet like impl pallet_treasury::Config for Runtime and before it you define the constants of that pallet with the parameter_types! macro but is not mandatory to have one parameter_types! defined before each pallet is just for readability, you can have one at the top of your code file with the constants of all pallets.

See this example in the Kusama runtime: The const MaximumReasonLength is defined once and used in the pallet_bounties and in the pallet_tips.

Another option is define it like a const, in the Kusama runtime take a look into the const VERSION defined here and used in the pallet frame_system and in the apis implementation here.

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.