A smart contract cannot produce an unpredictable number from its own state, because every validator has to compute the same result, which means players and block producers can compute it in advance as well. Contracts get randomness from outside the computation instead: from block data, from users in a commit-reveal round, from a protocol or threshold beacon, or from an oracle that delivers a value along with a way to check it.
Each of these sources leaves some party with a degree of influence over the outcome.
Block values make weak dice
On Ethereum, the Solidity documentation warns against relying on block.timestamp or blockhash for randomness, since block producers can influence both to some degree. blockhash also returns zero for anything older than the 256 most recent blocks. With 12-second slots, that comes to 256 × 12 = 3,072 seconds, about 51 minutes when no slots are missed. If a contract records a target block number and settles later, it has about 51 minutes to read that block's hash before the value drops to zero.
block.prevrandao returns the beacon chain's RANDAO mix, and EIP-4399 spells out its limits:
- Each block proposer holds 1 bit of influence per slot, and can also decline to propose so the mix does not update.
- A proposer can censor a dice-rolling transaction to push it into the next block.
- The EIP suggests committing to a value at least four epochs ahead. Ethereum runs 32 slots per epoch, so four epochs means 4 × 32 × 12 = 1,536 seconds, about 26 minutes of waiting.
Cardano's randomness guide gives a similar warning for its own chain: block producers can grind block randomness, and values such as the treasury amount stay public for a whole epoch.
Commit-reveal and the last revealer
In commit-reveal, each participant first posts a salted hash of a secret, then reveals the secret, and the contract combines the reveals. The Cardano guide points out the weak spot. The last participant to reveal has already read every other reveal, so that person can compute the result and refuse to reveal if they dislike it. Slashable deposits and reveal deadlines raise the cost of walking away. The same guide recommends combining reveals by sorting and hashing them, rather than with XOR.
Protocol beacons and threshold networks
Some chains build randomness into the protocol. IOTA exposes a Random object at address 0x8, which a Move function reads through a local generator, according to the IOTA docs.
drand produces publicly verifiable random values at fixed intervals, signed with threshold BLS signatures by a network of operators called the League of Entropy.
Oracles that return a value with a proof
A verifiable random function (VRF) oracle answers a request with a random value plus a cryptographic proof. In the design Chainlink described in 2020, the oracle combines block data unknown at request time with its pre-committed key, and an on-chain contract verifies the proof before passing the value to the consumer. A compromised node can withhold a response, but a manipulated output fails verification. Cardano describes the same pattern with an operator key registered in advance and the proof checked by the validator, where the operator keeps only the power to withhold.
Quantum randomness from QVRF
QVRF, Quip Network's randomness service, delivers numbers measured on quantum hardware to contracts through a request and a callback, as described in the QVRF docs. Its current trust model is centralized and simple:
- Quip runs both the randomness generator and the delivery service.
- Before delivery, Quip's oracle posts a Merkle root of the round's random words on-chain. The dispensing contract checks each delivered word's proof against that root and rejects words already spent, so Quip cannot slip in a value from outside the committed set.
- Quip can still influence results in two ways. The oracle sees a round before posting its root and can decline to publish it, and the trustee, also run by Quip, chooses which committed word serves which request.
- The audit of the quantum measurements runs off-chain, after delivery. Per quip.network/qvrf, on-chain verification contracts and a split between the oracle and trustee roles are in development.
The docs also explain why the name misleads: QVRF is a physical randomness source with a verification record, so the standard VRF security definitions do not apply to it.
The methods side by side
| Method | Value comes from | Who can still influence the result | How a contract checks it |
|---|---|---|---|
blockhash, block.timestamp |
Block producer | Block producers, to some degree | Reads chain data, hash only for the last 256 blocks |
block.prevrandao |
Beacon chain RANDAO mix | Each proposer: 1 bit per slot, or skip the slot | Reads chain data |
| Commit-reveal | Participants | The last revealer, by withholding | Hash of each reveal against its commitment |
Protocol beacon (IOTA Random) |
The chain's protocol | Callers who revert or compose around losing outcomes | Built into the protocol |
| Threshold beacon (drand) | League of Entropy operators | A threshold of operators acting together | BLS signature check |
| VRF oracle | Oracle key plus request-time block data | The oracle operator, by withholding | Proof verified on-chain |
| QVRF | Quantum hardware measurements | Quip as sole operator, by withholding a round or choosing which committed word serves which request | Merkle proof against an on-chain root at delivery, quantum audit off-chain |
Mistakes that break a good source
The drand team's list of gotchas and the IOTA docs flag these:
- Modulo bias. Taking
randomValue % 100from an 8-bit value makes results 0 through 55 more likely, because 256 does not divide evenly by 100. Rejection sampling, or a value at least 128 bits wider than the range, removes the skew. - Composition attacks. When a public function draws randomness and pays out in one call, an attacker can wrap the call and revert whenever they lose. IOTA counters this with private
entryfunctions and limits on what may follow aRandomcall in a transaction. - Gas differences. If the losing path costs more gas than the winning one, an attacker can set a gas limit that makes losing transactions fail. IOTA advises keeping the losing path no more expensive than the winning path.
- Packed encoding. Hashing several inputs with
abi.encodePackedcan produce collisions. Usingabi.encodekeeps each input distinct.
Next step
To compare QVRF's trust model with your contract's requirements, read the QVRF concepts page or request access at quip.network/qvrf. The earlier post on how QVRF delivers quantum randomness to smart contracts covers the request flow in more detail.
