← Developer Forum

Entropy·help question·✓ answered

Generating user Random Number

Open on dev-forum →Back to forum

Hi there, I have two questions regarding Pyth Entropy

  1. I read the Entropy docs to generate a random number. I don’t quite get what’s the difference between generating a random number doing something like “web3.utils.randomHex(32)” or “crypto.randomBytes(32)” and doing the whole entropy protocol process. If I want to create a dApp and I use the first option instead of the Entropy RNG protocol what difference does it make? The number will be completely random in both cases.

  2. The coin flip example in the pyth data github repo (https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/examples/coin_flip/contract/src/CoinFlip.sol) says:

users of this protocol can stall the protocol by choosing not to reveal their generated random number.
    // Developers using Pyth Entropy should ensure that users are always incentivized (or at least, not disincentivized)
    // to finish both stages of the protocol.

Does that example protect from it? And if so, how does it protect from it?

Showing the original post only. Read the full thread on dev-forum.pyth.network ↗

Replies: 1
Views: 484
Likes: 1
Posted: 4/6/2025

Source: https://dev-forum.pyth.network/t/generating-user-random-number/36 · external id 36