Skip to main content

API reference

We provide libraries in multiple languages for verifying and deriving random numbers from our network, as well as performing common gaming tasks for randomness that are easy to get wrong.

Installation​

Make sure you have an up-to-date version of cargo, and add the following to your Cargo.toml:

[dependencies]
randamu-rand = "0.0.1"

Pick a random integer​

use drand_sdk_rs::KeccakSdk;

// Fetch the random bytes from chain or somewhere else:
let randomness: Vec<u8> = .. ;

// Initialise the SDK using Keccak for derivation (for compatibility with EVM smart contracts).
// Other hash functions and XOF are available.
let mut rng = KeccakSdk::new().new_int_rng();

// Now we can get the same random number as every other SDK user would.
// The bitsize will depend on which generic parameter we pass
let random_int: u64 = rng.next_unsigned<u64>()?;