# 🎟️ Ticket

The Ticket contract is an [ERC20](https://eips.ethereum.org/EIPS/eip-20)-compatible token that allows users to be selected by a token index.

The contract organizes the balances into a sum tree data structure, so that each address holds a "range" of tokens.  A number can be used as an index within that range, and the holder of the tokens in that range is selected:

```javascript
function draw(uint256 randomNumber) public view returns (address)
```

The **randomNumber** will be used as a token index into a specialized data structure that stores the user balances.  The randomNumber is constrained to the token supply and modulo bias is corrected.

The returned address is the user who holds the token index corresponding to the random number.


---

# 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://v3.docs.pooltogether.com/master-1/protocol/tokens/ticket.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.
