How to deploy randomness on Boba $BOBA

Rokowski
The Witnet Oracle Blog
3 min readSep 1, 2022

The Witnet network has been providing oracle services to the Boba Network since September of 2021.

Why the Witnet oracle is easy to use for randomness on Boba

Because Witnet is a layer 1 blockchain running on it’s own single-purpose built network, it’s very simple to integrate both onto new chains, and into your applications. Witnet is currently providing data and randomness to 18+ different EVM compatible chains, see some more projects using Witnet here.

The best part is that you don’t actually need to hold any of the $WIT coin, the native coin of the Witnet ecosystem that powers the cryptoeconomic incentive of the network. Developers who want to query the Witnet network are paying fees related to that query in the native coin of the chain they are building on, in this case, $BOBA.

How to use the Witnet oracle for randomness in your application on Boba

The WitnetRandomness contract, also known as the Witnet Randomness Oracle, is the easiest and most convenient way to generate EVM-agnostic and reliable randomness for your smart contracts. You can see some solidity examples on this page.

However, you will then need to add logic within your smart contract as to await for an answer from the Witnet side-chain and handle corner-case revert situations at the Witnet level, before feeding your favorite Pseudo Random Number Generator (PRNG) algorithm with the 32-byte random seed provided by the Witnet oracle.

In a nutshell, by using a WitnetRandomness you just need to:

  1. Eventually, care for requesting and paying for new randomness at any given time: see randomize() payable.
  2. Eventually, fetching a randomness value generated by Witnet after any given block number: see isRandomized(uint256) and getRandomnessAfter(uint256).

Some common troubleshooting is that you must wait around 5 and 10 minutes from when you requested the random number to when you can use it. This is because Witnet’s random number function is asynchronous to protect from manipulation and predictability as it guarantees that the number was generated only after the request was sent.

For example, fetchRandomNumber() or fulfillRandomness() will most likely revert if you have just called getRandomNumber() or requestRandomness()

For a more in depth explanation, take a look at the documentation page here. You can also read the contract directly from the BobaScan explorer, or the BobaScan Rinkeby one.

If there are any questions or you need access to more resources, please join our Discord, choose the “developer” role (optional), and navigate to #-dev-lounge or #-solidity and our community can help! In addition, the Witnet oracle is capable of fetching any publicly available API through HTTPS Get, Post, and GraphQL. Furthermore, the Witnet price feed oracle is available for your synthetics, stablecoins, betting, and more!

Also, The Witnet Foundation recently launched the grant program. If you are building a project on Boba and want to use Witnet, you might be eligible for a grant! Read more and apply here.

Connect with Witnet:

Website | GitHub | Twitter | Discord | Telegram | Reddit | YouTube

--

--