Nois Network v0.8.0: Enhancing the Reliability, Usability and Modularity of Randomness on Cosmos

Baccour Kais
Coinmonks
7 min readJan 3, 2023

--

Nois in the cosmos

Introduction

Randomness is a crucial aspect of many blockchain applications, from games of chance to decentralized exchanges. Without true randomness, these applications can be vulnerable to exploitation and manipulation.

The Nois Network aims to provide a decentralized, verifiable source of randomness for the Cosmos ecosystem. In the latest release, v0.8.0, there have been several changes and improvements to the Nois contracts, including a split of the originally-named nois-oracle contract into two separate contracts: nois-drand and nois-gateway.

In this article, we will delve into the changes and improvements introduced in v0.8.0, and how they contribute to the overall security and modularity of the Nois Network. We will also take a closer look at the Nois Toolbox, a collection of transformations and utility functions that can be applied to the randomness generated by the Nois Network. These functions include the ability to pick elements randomly from a list (example: picking one hat among others for an unpredictable NFT character), shuffle a list , and generate random integers within a given range.

With these tools at their disposal, developers can easily incorporate verifiable randomness into their CosmWasm based smart contracts, adding an extra layer of security and fairness to their Dapps.

So without further ado, let’s dive into the changes and improvements introduced in Nois contracts v0.8.0.

The new v0.8.0 Nois contracts

Before the release of Nois v0.8.0, the nois-oracle contract served as the main entry point for interacting with the Nois network. It was responsible for handling randomness requests from consumer DAPPs, verifying submissions from drand bots, and managing the IBC (Inter-Blockchain Communication) logic for transferring data between chains.

Nois contracts before v0.8.0

In the latest release of the Nois network, version 0.8.0, Some significant changes have been made to the Nois contracts. These changes were necessary in order to improve the overall performance and modularity of the network as well as making some space to be able to include in the future new sources of randomness as well as allowing developers with no drand or BLS or maths knowledge to still be able to contribute to the Nois project. This is how the new Nois chain looks like.

Randomness flow in v0.8.0.

As you can see here, one of the main changes in v0.8.0 is the separation of the nois-oracle contract into two separate contracts: nois-drand and nois-gateway. The nois-drand contract is responsible for verifying submissions from the drand bots, while the nois-gateway contract handles the callback jobs from DAPPs and IBC logic.

Requesting the randomness

From a Dapp standpoint, the flow does not change at all since the previous Nois flow. All the Dapp cares about is to request randomness (1.a) to the nois-proxy contract that lives on the same chain. The nois-proxy will then relay the request to nois-gateway that lives on the Nois network (1.b).

requesting nois randomness

Receiving the randomness

From the other side of the chain, The Nois drand-bot operators retrieve the randomness from the drand API (2.a) and submit it to the nois-drand contract for on-chain verification (2.b). If the verification is successful (and fast enough), the bot is incentivized.

These drand bot operators can check their submission results in this dashboard. The ones in green are the faster bots that won the race for the incentive, and the bots in grey will hope to win the next drand round (in 30 seconds)

On chain randomness by nois
https://randomness.nois.network — Simon

Once the submission is verified by the nois-drand it is transferred to the nois-gateway contract(3), where it is stored in the contract’s state. The nois-gateway contract keeps track of which randomness rounds have been requested, by whom, and on which consumer chain. It uses a queue system to manage pending requests and sends callback messages to consumer DAPPS as soon as the randomness becomes available.

This diagram shows in more details how the nois-gateway contract works

Nois contracts v0.8.0

Overall, this separation allows for a more modular and scalable design, as the two contracts can now focus on their specific tasks without overlap. It also improves the security of the network, as the verification of submissions can be handled separately from the rest of the process.

Releasing nois-toolbox v0.6.0

The nois-toolbox is a collection of functions and utilities that allow developers to easily incorporate the verifiable randomness coming from the Nois chain into their CosmWasm applications by importing the Nois dependency into their code. As a developer, you feed the nois-toolbox a raw randomness coming from Nois and it will magically transform it into something more useful for your contract. Here are some of the features and use cases of the Nois toolbox:

  1. coinflip: This function allows developers to simulate a coin flip, with a 50% chance of returning either "heads" or "tails". This can be useful in applications that require a simple means of randomness, such as games of chance or decision-making processes or simply a coin flip casino game.
  2. roll_dice: This function allows developers to simulate the rolling of a traditional six-sided dice. It returns a random integer between 1 and 6.
  3. int_in_range and ints_in_range: These functions allow developers to generate a random integer within a given range following a uniform distribution. int_in_range() returns a single integer, while ints_in_range() returns a list of integers. These functions can be useful in applications that require random numbers for various purposes, such as shuffling a deck of cards or selecting a random winner in a contest as well as rolling multiple dice.
  4. pick: This function allows developers to randomly select a specified number of elements from a list. This function can be useful in applications that require random selection, such as drawing names from a hat, choosing a random subset of items from a larger list or simply drawing raffle or lottery winners: You could use pick to randomly select a certain number of winners from a list of participants.
  5. random_decimal: This function allows developers to generate a random decimal value between 0 and 1.
  6. sub_randomness and sub_randomness_with_key: These functions allow developers to generate a stream of sub-randomnesses based on a given randomness and optional key. This can be useful in applications that require multiple instances of randomness, such as rolling multiple dice or shuffling multiple decks of cards.

The toolbox also includes a JavaScript WebAssembly wrapper, which allows developers to use these functions in a browser environment. For example, this wrapper has been used in the Nois Randomness Simulator (https://nois-randomness-simulator.vercel.app/), which allows users to simulate the generation of random values using the toolbox.

https://nois-randomness-simulator.vercel.app/rounds/2578285 — LeTurt

Conclusion

The Nois network offers a valuable solution for providing secure and verifiable randomness to the Cosmos ecosystem. The latest release, v0.8.0, brings important changes and improvements to the Nois contracts, including the split of the nois-oracle contract into nois-drand and nois-gateway.

Additionally, the nois-toolbox v0.6.0 offers a variety of functions for generating and utilizing randomness in various contexts. From selecting winners in a contest to shuffling a deck of cards, the toolbox has you covered. With the release of the JS/WASM wrapper, it’s now even easier to incorporate randomness coming from Nois into web-based applications, or simply allow the users of your Dapp to verify the outcome of your Dapp so the process happens in a trustless manner.

Overall, Nois is a valuable resource for anyone looking to add a layer of unpredictability and fairness to their blockchain projects. For more information, be sure to check out https://nois.network.


T

New to trading? Try crypto trading bots or copy trading on best crypto exchanges

--

--