A simple random number generator in Move language.
- Constants
- Function
bytes_to_u64
- Function
bytes_to_u128
- Function
rand_u64
- Function
rand_u64_with_count
- Function
rand_u128
- Function
rand_u128_with_count
- Function
rand_u64_range
- Function
rand_u64_range_with_count
- Function
rand_u128_range
- Function
rand_u128_range_with_count
use 0x1::hash;
use 0x1::option;
use 0x1::vector;
use 0x2::bcs;
use 0x2::timestamp;
use 0x2::tx_context;
use 0x3::transaction;
const ErrorInvalidArg: u64 = 0;
const ErrorInvalidSeed: u64 = 3;
const ErrorInvalidU128: u64 = 2;
const ErrorInvalidU64: u64 = 1;
public fun bytes_to_u64(bytes: vector<u8>): u64
public fun bytes_to_u128(bytes: vector<u8>): u128
Generate a random u64 from seed
public fun rand_u64(): u64
Generate a random u64 value with a count parameter to ensure unique randomness within a transaction.
public fun rand_u64_with_count(count: u64): u64
Generate a random u128 from seed
public fun rand_u128(): u128
Generate a random u128 value with a count parameter to ensure unique randomness within a transaction.
public fun rand_u128_with_count(count: u64): u128
Generate a random integer range in [low, high) for u64.
public fun rand_u64_range(low: u64, high: u64): u64
Generate a random integer range in [low, high) for u64 with count.
public fun rand_u64_range_with_count(low: u64, high: u64, count: u64): u64
Generate a random integer range in [low, high) for u128.
public fun rand_u128_range(low: u128, high: u128): u128
Generate a random integer range in [low, high) for u128 with count.
public fun rand_u128_range_with_count(low: u128, high: u128, count: u64): u128