Randomness
Last updated
Was this helpful?
Last updated
Was this helpful?
In October 2021, a new Random Number Generator (RNG) capability was added to the Witnet protocol, allowing for secure sourcing of random numbers and byte arrays into smart contracts.
This is specially useful for lotteries, gaming, and assigning randomized sets of traits to NFT collection items to make them unique.
On each of the there is an instance of the WitnetRandomness
contract that exposes the main randomness oracle functionality through a very simple interface.
The best way to interact with the WitnetRandomness
contract is through the IWitnetRandomness
interface, which is readily available in the .
This example shows how easy is to source random uint32
values into your own contracts:
This 2-step process preserves unpredictability of the random numbers that you get because it guarantees that the number is derived from a seed that was generated only after the request was sent.
You can find here the complete documentation and API reference for the Witnet randomness oracle, along many more examples and walkthroughs: