Flow Community Rewards are here. Earn points for engaging in the ecosystem, spend points on prizes. Learn more.
Developers
November 8, 2023
On-chain Randomness On Flow
Ali Serag
On-chain Randomness On Flow

Introduction

We live in a world where chance is baked into our everyday lives; from the roll of dice in a child’s board game to the vast complexities of financial systems. Within all this unpredictability, we are both enthralled and liberated by randomness. It fuels industries, ignites the thrill in games, and stands as a guardian of equity in everything from visa lotteries to deciding who gets to eat the last piece of pizza. Although it permeates our daily lives, obtaining easily accessible and secure randomness on-chain has remained a major obstacle for Web3 developers, creating obstacles for both trust and innovation.

Randomness On-chain

We have just released a breakthrough on-chain random number generator that goes live today! This innovative protocol uses a ‘randomness beacon’ which generates an unbiased, unpredictable, and verifiable source of secure pseudo-randomness in a fully decentralized manner. The values are efficiently generated and impossible to predict until the protocol produces them. The source of randomness is created for every block and is not part of the block itself. This allows the random value to operate with a degree of autonomy from the blockchain's core operational processes, safeguarding the generated randomness from potential biases and manipulations, particularly those that could be introduced by validators.

The lack of effective, simple, and secure random number generators in Ethereum has introduced numerous workarounds that contribute to severe smart contract vulnerabilities, contestable outcomes and ultimately - lost funds. The blockchains that do provide randomness, often offer non-secure per-block random number generation natively within the protocol. Developers on these other chains commonly have to choose between using insecure random numbers available, designing their own on-chain solutions with weak security guarantees, or fall back to off-chain ‘randomness oracles’, such as Chainlink VRF or drand. Flow now ensures a built-in, secure and fraud-proof randomness that can be seamlessly integrated into smart contracts at no cost, enhancing security and bolstering trust in applications.

You can read about the technical specifics and join the conversation on the official Forum.

Harnessing Randomness in Web3 Innovation

Randomness has massive implications for diverse types of applications and industries, the following explore just a few examples of what can be unlocked on Flow as of today:

  • AI & NPCs: The integration of robust randomness within AI and Web3 initiatives. By implementing domain randomization (DR) and other model-free learning frameworks, we're able to introduce a layer of unpredictability into systems that simulate the real world with unparalleled accuracy. An AI could be taught to anticipate and react to a spectrum of possibilities, echoing the unpredictable nature of life leading to accurate simulations - ranging from climatic models to market forecasts. Here randomness challenges preconceived notions and models, compelling them to withstand and adapt to a multiplicity of conditions which unlocks novel use-cases such as censorship resistant AI ‘NPCs’ that can lead DAOs and formulate reactive DeFi strategies.
  • Art: In the artistic realm, generative algorithms are utilizing randomness to conceive works that are as unique and unpredictable as human-made art, pushing the frontiers of creativity into uncharted territories. Generative Web3 games can not only continually generate assets but also music through algorithms that compose melodies never imagined by human minds before.
  • NFTs: When it comes to the minting of NFTs, randomness injects a thrilling element of surprise, ensuring each digital asset is a singular treasure, thus magnifying its desirability and collectible value. This unpredictability isn't just exciting—it's a building block for creating a market based on scarcity and originality.
  • Gaming: Various functionality critical to gaming will become available for web3 game developers including everything rom loot-boxes to player vs player matchmaking, random damage dealt and traits generation.
  • Gambling A plethora of gambling applications become possible by fairly determining the outcome of events based on random selection such as selecting lottery winners in luck-based draws.
  • Defi: Decentralized exchanges can leverage randomness to order trades and prevent front-running, ensuring the order book is unbiased and yield farming can utilize randomness in allocation of rewards.

Randomness not only strengthens the foundation of digital trust but also unleashes a spectrum of possibilities, allowing developers and creators to craft experiences as unpredictable and vibrant as the everyday world we live in.

Conclusion

The introduction of the random protocol on Flow constitutes a substantial enhancement to critical Web3 infrastructure. It equips developers with an accessible and secure way to build  smart contracts that rely on randomness while ensuring that they operate with impartiality. It unlocks new applications across billion dollar industries with massive implications for gaming, DeFi and NFTs, AI and autonomous systems.

Ready to get started? Play around with your own random number generator or explore the developer docs.