The Parameters Pallet¶
Introduction¶
The Parameters Pallet on Moonbeam is a governance-focused module that enables community-driven modifications to key network configuration items, such as the deposit requirement for the randomness module, directly on-chain through proposals and votes, without necessarily requiring a runtime upgrade. By removing the need for frequent code changes, the Parameters Pallet allows the network to respond more quickly to evolving needs while maintaining transparency and consensus.
This guide will provide an overview of the extrinsics, storage methods, and getters for the pallet constants available in the Parameters Pallet on Moonbeam. This guide assumes you are familiar with governance-related terminology; if not, please check out the governance overview page for more information.
Parameters Pallet Interface¶
Extrinsics¶
The Parameters Pallet provides one extrinsic (functions):
setParameter(keyValue) - sets the value of a parameter
keyValue
- the key to the storage item to be modified
Suppose you want to adjust the deposit parameter for the randomness pallet. You'd start by crafting a call to the setParameter
function, specifying the randomness pallet's key and the new deposit value. In Polkadot.js Apps, this involves selecting parameters.setParameter(keyValue)
and then updating the deposit field for PalletRandomness
. While you can generate and review this call data beforehand, the actual change must still go through the governance process—meaning it needs to be proposed, voted on, and approved by the community before the new deposit value takes effect on-chain
// This is an example of crafting the encoded call data via the Polkadot API
// but remember you won't submit the call here as it needs to go thru governance.
import { ApiPromise, WsProvider } from '@polkadot/api';
const main = async () => {
// Replace with your node's WSS endpoint
const provider = new WsProvider('INSERT_WSS_ENDPOINT');
const api = await ApiPromise.create({ provider });
// Construct the setParameter call for changing the randomness deposit
// Keep in mind that actual submission must go through governance (proposal, voting, etc.)
const tx = api.tx.parameters.setParameter({
PalletRandomness: {
// The deposit parameter is declared as a tuple: (variant, Option<u128>).
// Here we're setting the deposit to 5 tokens (5000000000000000000),
// e.g., 'MoonbaseRuntimeRuntimeParamsDynamicParamsPalletRandomnessDeposit' is the variant,
// and the second element is the actual deposit value in the Option<u128>.
Deposit: [
'MoonbaseRuntimeRuntimeParamsDynamicParamsPalletRandomnessDeposit',
'5000000000000000000',
],
},
});
// Print out the call in hex format (useful for creating a governance proposal)
console.log('Encoded call data:', tx.toHex());
await api.disconnect();
};
main();
Storage Methods¶
The Parameters Pallet includes the following read-only storage methods to obtain chain state data:
parameters(parameters) - when queried with a parameter key, it returns either the corresponding value variant (e.g., RuntimeConfig
with FeesTreasuryProportion
) or None
if no value is set
parameters
- the name of the pallet combined with the specific key identifying the storage item to retrieve
The parameters
storage method is a dictionary that stores dynamic runtime parameters under specific keys. When queried with a parameter key, it returns either the corresponding value variant (e.g., RuntimeConfig
with FeesTreasuryProportion
) or None
if no value is set
import { ApiPromise, WsProvider } from '@polkadot/api';
const main = async () => {
// Replace with the appropriate WebSocket endpoint
const provider = new WsProvider('INSERT_WSS_ENDPOINT');
const api = await ApiPromise.create({ provider });
// Define the parameter key
const paramKey = {
RuntimeConfig: 'FeesTreasuryProportion',
};
// Query the storage
const currentValue = await api.query.parameters.parameters(paramKey);
if (currentValue.isSome) {
const unwrapped = currentValue.unwrap();
console.log('Unwrapped value (toHuman):', unwrapped.toHuman());
console.log('Unwrapped value (toJSON):', unwrapped.toJSON());
} else {
console.log('None. No value stored for the given key.');
}
// Disconnect once done
await api.disconnect();
};
main();
palletVersion() - returns the current pallet version
None
A number representing the current version of the pallet
// If using Polkadot.js API and calling toJSON() on the query results
0
import { ApiPromise, WsProvider } from '@polkadot/api';
const main = async () => {
const api = await ApiPromise.create({
provider: new WsProvider('INSERT_WSS_ENDPOINT'),
});
const palletVersion = await api.query.parameters.palletVersion();
console.log('The palletVersion is ' + palletVersion);
};
main();
Pallet Constants¶
The Parameters Pallet does not have any constants.
| Created: February 6, 2025