unc-rng 0.1.0

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
Documentation
  • Coverage
  • 0%
    0 out of 19 items documented0 out of 18 items with examples
  • Size
  • Source code size: 5.73 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 306.13 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Documentation
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • fadeAce

UNC-RNG

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

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;
  }
}