Crates.io | unc-rng |
lib.rs | unc-rng |
version | 0.1.0 |
source | src |
created_at | 2024-03-06 11:33:55.006988 |
updated_at | 2024-03-06 11:33:55.006988 |
description | This is a fork of tiny-rng https://github.com/JohnBSmith/tiny-rng to work with smart contract of the UNC protocol to minimize the binary size of the wasm |
homepage | https://github.com/Stolkerve/unc-rng |
repository | https://github.com/Stolkerve/unc-rng |
max_upload_size | |
id | 1164654 |
size | 6,068 |
Warning: Not cryptographically secure.
Examples:
use unc_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use unc_sdk::{env, near_bindgen};
use unc_rng::{Rng};
unc_sdk::setup_alloc!();
#[near_bindgen]
#[derive(Default, BorshDeserialize, BorshSerialize)]
pub struct Counter {
val: i32,
}
#[near_bindgen]
impl Counter {
pub fn increment(&mut self) {
let mut rng = Rng::new(&env::random_seed());
let value = rng.rand_range_i32(0, 20);
self.val += value;
}
}