Expand description

Randomness Pallet

The Randomness Collective Flip pallet provides a random function that generates low-influence random values based on the block hashes from the previous 81 blocks. Low-influence randomness can be useful when defending against relatively weak adversaries. Using this pallet as a randomness source is advisable primarily in low-security situations like testing.

Public Functions

See the Module struct for details of publicly available functions.



Import the Randomness Collective Flip pallet and derive your pallet’s configuration trait from the system trait.

Example - Get random seed for the current block

use frame_support::traits::Randomness;

pub mod pallet {
    use super::*;
    use frame_support::pallet_prelude::*;
    use frame_system::pallet_prelude::*;

    #[pallet::generate_store(pub(super) trait Store)]
    pub struct Pallet<T>(_);

    pub trait Config: frame_system::Config + pallet_randomness_collective_flip::Config {}

    impl<T: Config> Pallet<T> {
        pub fn random_module_example(origin: OriginFor<T>) -> DispatchResult {
            let _random_value = <pallet_randomness_collective_flip::Pallet<T>>::random(&b"my context"[..]);


pub use pallet::*;


The module that hosts all the FRAME types needed to add this pallet to a runtime.