1.0.3 • Published 2 years ago

@astra-js/rng v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Astra RNG

For use as secure rng in smart contracts on the Astra Blockchain

Usage

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@astra-js/rng/rng.sol";

contract Contract is RNG {

    // guess the number 1-10
    function guessNumber(uint8 num) public view returns (bool) {
        require(num > 0 && num <= 10, "Number has to be between 1 and 10");
        uint8 computerGuess = rng() % 10;
        return num == computerGuess;
    }
}