back13 Mar 20244 min read
blog post image

Pyth Entropy: Random Number Generation for Blockchain Apps

Pyth Entropy is an innovative approach for delivering secure random numbers on the blockchain and has launched on mainnet. Entropy is a response to the community’s demand for a fast and cheap source of on-chain randomness.

Pyth Entropy enables smart contract developers to tap into a secure and reliable source of randomness on-chain. Trustless RNG is critical for Web3 applications designed to deliver unpredictable outcomes across gaming, NFTs, lotteries, betting markets, and more.

Developers on Arbitrum, Blast, Chiliz Chain, Mode, LightLink, Optimism are the first to have access to Entropy on their native mainnet environments.


The Need for Secure Random Numbers

Many blockchain applications rely on a secure source of randomness to produce an unpredictable outcome or unique experience. Common use cases for on-chain random numbers include gaming and GameFi, NFT drops, and prediction markets in DeFi.

Developers building a gaming app, for example, may want to create unpredictable outcomes or obstacles for players. NFT minting and distribution activities can tap into a reliable source of randomness to yield truly unique mints and randomly selected recipients. Betting or parimutuel markets can base winning conditions on a source of randomness as opposed to real-world sports and events, like in on-chain roulette or virtual horse racing.

In these examples, the outcome must be truly unpredictable in order to be fair to participants and secure against manipulation. Furthermore, users demand perfect up-time and responsiveness from the apps they use.

Generating secure random numbers on a blockchain poses unique challenges due to the deterministic nature of blockchain states. Developers seek a source of randomness which is reliable, decentralized, and inexpensive, as shortcomings in these dimensions can hamper the final user experience.

Introducing Pyth Entropy

Pyth Entropy addresses these pain points by employing a novel approach to secure random number generation based on a two-party commit-reveal protocol, a well-known cryptographic technique. In this protocol, two parties can interact to generate a random number without needing to trust the other party.

  1. Commitment Phase: Both parties independently generate a secret random number and keep it a secret. They then hash this number and share it with each other by committing the hash to the blockchain.
  2. Reveal Phase: Both parties reveal their random numbers. The other party verifies that the counter-party’s revealed number matches the committed hash. The final secure random number is then obtained by hashing the two revealed numbers.

Pyth Entropy expands on this basic technique to improve its security and efficiency when running on the blockchain. First, the protocol allows one party to commit to a large quantity of random numbers up front, which minimizes the number of transactions required to operate the protocol. Second, the protocol mixes the chain’s blockhash into the result to add an additional source of random variation. While Pyth Entropy works differently from other random number generation approaches such as VRF, it is just as secure as these other approaches.

Properties of Entropy

Pyth Entropy empowers developers to deliver the user experience they envision by offering a secure, reliable, and fast solution for random number generation.

Security: Pyth Entropy is built on a commit-reveal protocol offering robust security guarantees and continuous responsiveness. This protocol minimizes trust between the participants, and Entropy users who follow the protocol can guarantee that the results are truly random.

Speed: Pyth Entropy follows a pull design similar to Pythnet Price Feeds. In the Entropy protocol, the two parties can communicate over HTTP instead of the blockchain itself. This design choice enhances the speed and simplicity of Entropy compared to other RNG alternatives.

Ease of Use: Integration with Pyth Entropy is straightforward and requires just a few lines of code. Similar to Pyth Price Feeds and Benchmarks, integration with Entropy is permissionless.

“Entropy’s launch on Mode will enable devs building out GameFi to securely get random numbers on-chain. This has been highly demanded since our launch and we are excited to work with Pyth to grow the use of Entropy SDK.” — James Ross, Founder of Mode

“The participants of the LightLink Gasless Hackathon had an excellent experience with Pyth Entropy and built innovative games with it. It is simple, reliable, and easy to integrate, and we witnessed several cool projects being developed.” — Roy Hui, Co-Founder and CEO of LightLink


Who’s Using Pyth Entropy?

Integration with Entropy is permissionless, and a number of creative and market-based projects are already tapping into the Entropy protocol to power their solutions.

FLAP (Blast)—a bundle market for blue chip NFT mints.

Fungible Flip (Blast)—a coin flip game with no house rake and true 50/50 odds.

SlashToken (Chiliz Chain)—a platform designed to provide user-friendly NFT and token tooling for Web3 projects.

Developers are invited to reach out and learn more about how Pyth Entropy can support their products. See the documentation for more.

Resources


We want to hear your feedback. Join the Pyth Discord and Telegram, and follow Pyth on X. You can also learn more about Pyth here.

Stay Updated with Pyth

Stay informed about Pyth network's development and upcoming events!

Recommended For You

all posts