๐ฒUsing Witnet Randomness
The Wit/Oracle Framework is a set of smart contracts deployed by the Witnet Foundation on a wide selection of EVM chains and L2s. This framework enables bidirectional interconnection between smart contracts and the Witnet blockchain.
The Witnet blockchain not only facilitates retrieving, aggregating, and notarizing real-world data on-chain but also serves as an unbiased and unpredictable source of randomness for smart contracts.
The Wit/Oracle Framework contains the WitRandomness utility contract, which basically allows anyone to request new randomness from Witnet by paying a small fee in EVM gas tokens (i.e. requesters), and anyone to freely fetch Witnet-generated randomness (i.e. consumers), even if requested by others.
Two randomness consumption models are supported:
Active Consumers
Fetch previously generated random seeds on a WitRandomness address and within EVM transactions initiated by some EOA.
Passive Consumers
Receive a call once a previously requested random seed is generated and reported back from Witnet, within some rollup transaction initiated by the Wit/Oracle bridging infrastructure.
To guarantee the impartiality and unpredictability of the random seeds provided by WitRandomness contracts, the following key aspects must be considered:
Unpredictability
Active consumers must specify the EVM block number after which randomness must have been generated in Witnet, whereas passive consumers should gate the EVM block at which the provided random seed was actually requested.
Unbiasedness
On-chain randomization requires a two-step process. First, each randomization request is relayed to Witnet as an oracle query transaction. After several blocks, Witnet provides a new 256-bit random seed for each request. These results are sent back to the WitRandomness contract in the order they were made.
Why is it different to other oracle solutions?
The random seeds generated by WitRandomness contracts within the Wit/Oracle Framework are trackable and verifiable. Each seed has an on-chain trail that allows users to trace the randomness generation process in Witnet, ensuring the transparency and trustworthiness of any on-chain outcomes derived from these seeds.
Actively reading randomized seeds
Actively reading Witnet-certified randomness is pretty cheap and simple:
Passively processing randomized seeds
Passive consumers only need to confirm that the reported seeds were actually requested on or after a specific reference block number:
Requesting on-chain randomness
To request on-chain randomness, you must pay a small fee in EVM gas tokens. This fee only depends on the gas price of the EVM transaction invoking the IWitRandomness.randomize() method:
Learn more about Witnet Randomness
For more information on how to interact with WitRandomness contracts, please go to:
๐ Check the comprehensive documentation and API reference for WitRandomness contracts. You will find numerous examples and guides on deriving multiple random numbers from a single seed, and details on setting up your own randomization infrastructure to eliminate reliance on third-party providers.
Last updated
Was this helpful?
