Crate nois

Source
Expand description

§nois

nois is a collection of utilities to help you interact with the Nois network Use this library to :

  • Integrate your app with the nois proxy.
  • Safely transform and manipulate your randomness.

Structs§

NoisCallback
This must be accepted in an NoisReceive { callback: NoisCallback } enum case in the ExecuteMsg of the app.
SubRandomnessProvider

Enums§

ProxyExecuteMsg
RandomnessFromStrErr
ReceiverExecuteMsg
This is just a helper to properly serialize the above callback. The actual receiver should include this variant in the larger ExecuteMsg enum.
Side
The side of a coin. This is the result type of coinflip

Constants§

MAX_JOB_ID_LEN
Max length that the job ID is allowed to have (in bytes)

Traits§

Int
A trait to restrict int types for int_in_range

Functions§

coinflip
Takes a randomness and returns the result of a coinflip (heads or tails).
int_in_range
Derives a random integer in the range [begin, end], i.e. including both bounds. Use this method to avoid a modulo bias.
ints_in_range
Derives random integers in the range [begin, end], i.e. including both bounds. Use this method to avoid a modulo bias. The resulting vector will contain exactly count elements.
pick
Picks n elements from a given list.
random_decimal
Returns a Decimal d with 0 <= d < 1
randomness_from_str
Takes a hex string and decodes it. Input must be 64 hex characters long (32 bytes).
randomness_simulator
Creates a predictable randomness seed
roll_dice
Returns a number from 1-6.
select_from_weighted
Selects one element from a given weighted list.
shuffle
Shuffles a vector using the Fisher-Yates algorithm.
sub_randomness
Takes a randomness and a key. Returns an arbitrary number of sub-randomnesses.
sub_randomness_with_key
Takes a randomness and a key. Returns an arbitrary number of sub-randomnesses. The key is mixed into the randomness such that calling this function with different keys leads to different outputs. Calling it with the same key and randomness leads to the same outputs.