# Random Number Generation

<figure><img src="/files/zZqQVvSd6T1pBbbYxt5i" alt=""><figcaption><p>Proof of fairness — every random number used by a Celestium game is generated and verified on-chain</p></figcaption></figure>

## How It Works

Celestium's dynamic games use **Chainlink VRF** (Verifiable Random Function) to produce the random numbers that decide round outcomes. VRF is built around three steps that the smart contract enforces end-to-end:

1. **Request** — the game contract sends a randomness request to the VRF coordinator on Polygon. The request is logged on-chain with the round ID it belongs to.
2. **Generation with proof** — a Chainlink oracle node generates the random value off-chain using a private key, and produces a cryptographic proof that ties the value to that key and the original request.
3. **On-chain verification** — the value and proof are returned to the game contract. The contract verifies the proof against the public key of the oracle before applying the value to the round. If the proof fails, the value is rejected.

The result is that no party — not the operator, not the validator, not Chainlink — can substitute a different number after the request is made. The proof is the audit trail.

## Integration

Every dynamic game wired to dynamic staking ([Roulette](/dexgames/games-guide/roulette.md), [Lotto](/dexgames/games-guide/lotto.md)) uses VRF for its round resolution. Players can inspect the VRF request, the response, and the proof directly in the Polygon transaction logs for any past round.

<figure><img src="/files/FG5736N9fr8AjIjHaijZ" alt=""><figcaption><p>Transaction logs — the random value and its proof returned by Chainlink VRF</p></figcaption></figure>

## Benefits

* **Cryptographically tamper-proof** — the on-chain proof check makes substitution impossible after the request.
* **User-verifiable** — anyone with a Polygon block explorer can audit any past round's randomness.
* **Decentralized oracle architecture** — the VRF network is not controlled by Celestium or by a single oracle operator.

## Related

* [Chainlink & Datafeeds](/dexgames/proof-of-fairness/chainlink-and-datafeeds.md) — the price-feed counterpart used by conservative games.
* [Lotto Round & Winners Protection](/dexgames/proof-of-fairness/lotto-round-and-winners-protection.md) — how the protocol guarantees winning payouts before a round is even spun.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.celestium.digital/dexgames/proof-of-fairness/random-number-generation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
