pub trait Randomness<Output> {
    fn random(subject: &[u8]) -> Output;

    fn random_seed() -> Output { ... }
}

Required methods

Get a “random” value

Being a deterministic blockchain, real randomness is difficult to come by. This gives you something that approximates it. At best, this will be randomness which was hard to predict a long time ago, but that has become easy to predict recently.

subject is a context identifier and allows you to get a different result to other callers of this function; use it like random(&b"my context"[..]).

Provided methods

Get the basic random seed.

In general you won’t want to use this, but rather Self::random which allows you to give a subject for the random result and whose value will be independently low-influence random from any other such seeds.

Implementors