Random numbers in Solidity for Ethereum using the Niguez Randomity Engine Introduction Generating a number from the blockchain as an entropic source is a formidable task, especially when the influence the , and , this may change as the network adheres to (Casper POS, Serenity). It depicts a stern complication for programmers who endure establishing a trust-less internal source of entropy for , whose essence inclines to be transparent. pseudorandom miners block gas limit block-hash block time Proof of Stake deterministic Ethereum blockchain The complication Since the blockchain is conspicuous, on the blockchain is evident to all the existing nodes for verification. Nevertheless, reverse-engineering ( ) bytecode back to in a stack-based architecture is computationally impossible due to name omission of , and ; particularly if the is optimised, obfuscated and self-modifying, the may generate but this is far from the . This settles one issue and generates another as there is a perception of reluctance and lack of confidence to interact with a . EVM bytecode decompile perfect original source code variables functions types smart contract decompiler pseudo-code original closed source smart contract The solution The in their raw form are susceptible to or (In POW or Future Casper POS) by various parties. The solution to this problem is extensively mixed hashing ( ) of the contributing factors to the point that influencing and predictions prove on the final hash output. block variables influence effortless prediction keccak256 block variables ineffective The problem here is after all the the of such smart contract ( ) will identify what the outcomes of certain are and hence may use this to their . Therefore, no entity will use such a facility as it is imperative and necessary to provide a and customisations to the random number end users. mixed hashing creator Niguez Randomity Engine blocks advantage degree of freedom The numbers generated are of . The end user could use , , in a sequence and it. Thus, the has due to the fact that the . Accordingly, the smart contract creator is and the or a user picked. Consequently, a user can only have control over the customised but of the avoiding prediction of numbers all through. pseudorandom 24 sequences unsigned integers of 256 bits any sequence cross sequence allocate a slot re-hash smart contract creator no influence contract is immutable incapacitated to comprehend influence sequences slots of the random number sequence they generate not the outcome random number, What is Niguez Randomity Engine? is a deployed on the that functions on the foretold protocol. It is immutable, providing impulsive sequences of with every . Niguez Randomity Engine smart contract Ethereum and ThunderCore blockchain pseudorandom number block In the of influenced , Niguez Randomity Engine makes them redundant due to its very essence. It is an and cannot the by the user. It serves as an for random numbers. scenario blockchain variables immutable smart contract predict and dictate slots determined escrow In pseudorandom number, the tends to repeat, that is not the instance with this as it uses a function. Hence, every sequence is and ; if the repeat, that would be considered an instance of a . conventional pattern randomity engine cryptographic hash non-repeating unique sequences hash collision The engine still renders the sequence of even if the are unpublished. Utilities, the likes of ‘ ’ are because nothing is stored in the and the are . random numbers block variables web3.eth.getStorageAt() redundant storage contract dependencies self-modifying The are named from ‘ ’ to ‘ ’, that is 1 to 24 respectively. The below elucidates the of this . pseudorandom sequences generated alphabetically Ra Rx illustration mechanism randomity engine Block variables are hashed, rehashed and mixed to generate 24 sequences of (256bits) unsigned integer. Sequences (7 slots) in action for every new block. Usage The sequences can be used with , a simple example is demonstrated here. For the purpose of brevity, the use case has been limited here to of nine each. pseudorandom generated infinite possibilities nine mixed sequences slots Allocating slots for various pseudo-random sequences. This is purely an of how to set . If the classification is then the numbers will be picked from the , hence it is advised to use by the user to be assured that the is debilitated to the . instance customised slots for sequences static identical slots perpetually dynamic slots randomity engine creator predict slots beforehand is to use by any entity for personal or commercial purpose and to explore the boundaries of the system. However certain transactions will . Niguez Randomity Engine FREE state modifying consume gas Niguez Randomity Engine contract addresses Guide to generate random numbers using the Niguez Randomity Engine Import API into your project | Use the following code: pragma solidity ^ ; ; ; 0.5 .0 / / **For Ethereum* import "https://github.com/niguezrandomityengine/ethereumAPI/nreAPI.sol" / / **For ThunderCore* import "https://github.com/niguezrandomityengine/thundercoreAPI/nreAPI.sol" Create a Smart Contract as follow (Ethereum): pragma solidity ^ ; ; contract Randomness is usingNRE { } 0.5 .0 import "https://github.com/niguezrandomityengine/ethereumAPI/nreAPI.sol" Code function to use sequences and set slots, there are 24 sequences i.e., ra(), rb(), rc() up to rx(): Example 1: Using the explicit sequence to get a 10 digits random number. pragma solidity ^ ; contract Randomness usingNRE { { (ra()%( ** )); } } 0.5 .0 "https://github.com/niguezrandomityengine/ethereumAPI/nreAPI.sol"; import is function randomNumber () public view returns (uint256) return 10 10 Example 2: Using multiple sequences to generate 3 digits random number ranging from 0 to 999. This type of random number generation can be used to randomly select validators in a Proof of Stake (PoS) network. pragma solidity ^ ; ; contract Randomness is usingNRE { { (((rf()% )* )+((rx()% )* )+(rm()% )); } } 0.5 .0 import "https://github.com/niguezrandomityengine/ethereumAPI/nreAPI.sol" ( ) ( ) function randomNumber public view returns uint256 return 10 100 10 10 10 Example 3: Transaction of random numbers into state or local variable. The below transaction will consume gas, approximately (40k — 120k) gas per sequence. pragma solidity ^ ; ; contract Randomness is usingNRE { uint256 public randomNumber; event rNum(uint256 theNumber); { randomNumber = (((ru()% )* )+((re()% )* )+(rq()% )); } { uint256 randomGame = (((rj()% )* )+((rg()% )* )+(ri()% )); emit rNum(randomGame); } } 0.5 .0 import import "https://github.com/niguezrandomityengine/ethereumAPI/nreAPI.sol" /**State Variable. */ ( ) function stateRandomNumber public 10 100 10 10 10 /**Local Variable. */ ( ) function localRandomNumber public 10 100 10 10 10 Example 4: Using the slot of numbers from between the sequence and hashing it for distinct random sequence pragma solidity ^ ; contract Randomness usingNRE { { (uint256(keccak256((rw()/( ** ))%( ** )))); } } 0.5 .0 "https://github.com/niguezrandomityengine/ethereumAPI/nreAPI.sol"; import is function randomNumber () public view returns (uint256) return 10 20 10 12 These are merely 4 instances of generating a pseudo-random number, the user could use this numbers in infinite possibilities by using dynamic slot selections, cross stitching sequences and using them as a salt to hash with user’s address or nonce. Thank you for reading. Enjoyed it? Please Share it. Links Guide on GitHub Project Website ResearchGate | Whitepaper