> For the complete documentation index, see [llms.txt](https://hyperpot.gitbook.io/hyperpot-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hyperpot.gitbook.io/hyperpot-docs/provably-fair-randomness.md).

# provably fair randomness

HyperPot uses Pyth Entropy to settle draws.

The important property is that randomness is requested only after the round closes. This prevents players from knowing the winning seed before deposits are finalized.

## Draw Flow

1. Players deposit into a round.
2. The round closes.
3. HyperPot requests randomness from Pyth Entropy.
4. Pyth fulfills the randomness callback.
5. HyperPot computes the winning ticket.
6. The winner receives a claimable payout.

## Ticket Selection

The contract computes:

```solidity
ticket = randomWord % totalWeight;
```

Then it finds the deposit entry whose cumulative range contains that ticket.

Simplified:

```solidity
uint256 ticket = randomWord % totalWeight;

for each deposit:
    if ticket is inside deposit range:
        winner = deposit.player;
```

In the deployed contract, the lookup is implemented efficiently with binary search over cumulative deposit ranges.

## Why It Is Weighted

Each HYPE deposited increases the player's range.

If you own 40% of the total stake, you own about 40% of the ticket range.

## Pending Draws

Sometimes a round closes before the Pyth callback has arrived.

During that time, the UI may show:

```
PENDING DRAW
```

Once the callback arrives, the winner is selected and the next round opens.

## Stuck Draw Safety

If Pyth Entropy does not fulfill a draw within the contract's timeout window, the stuck draw can be cancelled.

Depositors can then claim refunds.

This exists as a safety hatch for oracle or infrastructure issues.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://hyperpot.gitbook.io/hyperpot-docs/provably-fair-randomness.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
