Random Number Generator (RNG) v1

Umbrella Oracle implements the Random Number Generator as a Layer 2 Data . The Random Number (RAND) is stored under the 'FIXED_RAND' key and its value is stored as bytes and represents a 256-bit number.

Note: In Block Explorer the key is presented as 'RAND' alone.

1135

One RAND is generated in each Oracle's block. This RN follows a uniform distribution.

Using the Random Number

Umbrella Network's Oracle includes 1 RAND per block. As nothing restrict your dApp from reading subsequent RANDs, you should be cautious when using the RAND so you give certainty about the randomness introduced into your smart contract. This is why we recommend defining ahead of time the block from which your dApp will be getting the RAND from.

Umbrella provides 2 alternatives for subscribing for a RAND included in a future block:

  • Passport Beta: For receiving the RAND directly into your smart contract, the Passport Beta should be used. Logic into the acceptPallet method in your smart contract must be included to determine if the RAND to be delivered is the expected one.

  • Layer-2 Notifier: L2Notifier is a smart contract to which you can subscribe and request a RAND for a future block. Details on how to use L2Notifier can be found in here. L2Notifier requires an off-chain module that fetches the RAND from Umbrella's API and submits it to the L2Notifier. L2Notifier will in turn confirm that the RAND submitted belongs to the subscribed block . If that is the case, L2Notifier will verify the RAND on-chain and deliver it to the subscriber smart contract.