Skip to main content

Raw randomness


Instead of getting random numbers, it is possible to use to get raw bytes of randomness. This enables you to develop much more complex apps and use cases where using numbers alone wouldn't be practical.

Why would I need raw randomness ? enables you to generate random numbers onchain that you can then use in your applications.

However in some cases, you may not be interested in getting the actual random numbers themselves but rather some raw bytes of randomness.

For example, if you need to generate a random string identifier. In this case, you would prefer to get the randomness as a string rather than as a list of numbers. This way, you would not need to make any conversion and could directly use the raw randomness as your string identifier.

Fortunately, this is something that we enable you to do. 🎉

How do I get the raw randomness ?

When making a randomness request you normally set the numbers parameter to the number of random numbers you want. Under the hood, will generate a 64-bit raw randomness for each random number you ask. Therefore, if you are interested in getting raw randomness, you need to set the numbers parameter to a multiple of 64 depending on how big you want the raw randomness to be.

For example if you need 256 bits of raw randomness you would set the numbers parameter to 4 because 256/64 = 4.

Then, instead of getting the random numbers by calling checkRandomNumbers(cid) you would get the raw randomness by calling checkRawRandomness(cid).

Raw randomness on Arbiscan In the example above, the raw randomness for the draw 0x7dab993f6b248a8354f74a45a0a58640b6da16a1736df22c25f06ad2608fb283 is 0x896191ed70949cdee8438ec9df986e0853d16b0078e13e66