mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 21:27:57 +00:00
e01ac8cea0
* contracts: Allow contracts to dispatch calls into the runtime * Fix RPC tests * Fix typo * Replace () by AllowAllFilter and DenyAllFilter * Add rust doc * Fixup for `()` removal * Fix lowest gas calculation * Rename AllowAllFilter and DenyAllFilter * Updated changelog
Randomness Module
The Randomness Collective Flip module 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.
Usage
Prerequisites
Import the Randomness Collective Flip module and derive your module's configuration trait from the system trait.
Example - Get random seed for the current block
use frame_support::{decl_module, dispatch, traits::Randomness};
pub trait Config: frame_system::Config {}
decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
#[weight = 0]
pub fn random_module_example(origin) -> dispatch::DispatchResult {
let _random_value = <pallet_randomness_collective_flip::Module<T>>::random(&b"my context"[..]);
Ok(())
}
}
}
License: Apache-2.0