# Random Prize Draw

This random prize draw example leverages the blockchain to ensure integrity and transparency. By using Event's linked records feature, every process step, from ticket generation to the final prize award, is generated by or recorded on the blockchain, ensuring that the entire prize draw is open for verification and audit in near real-time. This prevents tampering or manipulation, ensuring that participants can trust the fairness of the prize draw.

<figure><img src="/files/sJwLQjn6uwmFPjZnMzqs" alt="" width="563"><figcaption></figcaption></figure>

1. An operator devises a prize draw and advertises it globally. They create a linked record (**A** above) with details such as: the prize, maximum tickets, draw date, ticket price, terms, and conditions. The location of the linked record acts as a unique reference for the draw and can be published immediately.
2. When the operator creates a ticket, they update the linked records with a new entry (**B** above). This entry has a unique identifier that serves as the ticket number, which is then given to the holder.
3. The operator creates the number of tickets specified initially using linked records (**C**, **D**, **E** above) and distributes them to holders. For security, each ticket can include a unique code related to the ticket holder, and be encoded. This takes place in near real-time.
4. When the prize draw occurs, a unique random number is generated from the blockchain by writing a specific record to the linked records (**X** above).  This ensures transparency and fairness, as the operator does not know all of the inputs used to generate the random number, and they cannot attempt generating multiple random numbers.
5. The winning ticket is identified by the blockchain-generated random number and is added to the linked records (**Y** above) by the operator.
6. After the winner claims their prize, the operator closes the prize draw and finalises the linked records (**Z** above).

Note: the whole state of the prize draw is always on the blockchain in near real-time. The prize draw description, the tickets and the winner provenance may be verified by anyone at any time using readily available blockchain browsers.

### Benefits

* The records are irrefutably linked together on the blockchain.
* Records and timestamps are recorded.
* Transparency: Records are publicly accessible globally from the blockchain.
* A verifiable and irrefutable proof of the records exists on the blockchain (non-repudiation & tamper-proof).
* Uses the blockchain as a trusted global random number generator.

***Unique identifiers and random numbers***

See [here](/nchain-event/independent-records/tutorials/blockchain-unique-identifiers.md) for details about generating unique identifiers and random numbers.

***Example of this random prize draw on the blockchain***

Here is an example of this random prize draw on the blockchain.

Follow the links in the table to see the actual records on the blockchain.

Note: you can navigate through all the records in WhatsOnChain by clicking the first input link of each transaction for earlier records, or the last output link of each transaction for later records.

<table><thead><tr><th width="49.1015625">#</th><th width="160">Item</th><th>Value</th></tr></thead><tbody><tr><td>1</td><td>File Contents</td><td>Global Prize Draw on the blockchain for transparency. 4 tickets, followed by Random Selector and winner.</td></tr><tr><td></td><td>Encoding and Fingerprint</td><td>-</td></tr><tr><td></td><td><p>Location</p><p>(TXID, output #1)</p></td><td><a href="https://whatsonchain.com/tx/ec4e6bb1f04e68bf029e5e517ad041ef4343faed414cc3b46c30599b5ef1f385">ec4e6bb1f04e68bf029e5e517ad041ef4343faed414cc3b46c30599b5ef1f385</a></td></tr><tr><td>2</td><td>File Contents</td><td>Ticket1</td></tr><tr><td></td><td>Encoding and Fingerprint</td><td>-</td></tr><tr><td></td><td><p>Location</p><p>(TXID, output #1)</p></td><td><a href="https://whatsonchain.com/tx/98c986fc0d1ce8df55faf4734324aeef602298931ba5e5aedfcff9711cd50926">98c986fc0d1ce8df55faf4734324aeef602298931ba5e5aedfcff9711cd50926</a></td></tr><tr><td>3.1</td><td>File Contents</td><td><p>Ticket2</p><p>Flower: Pansy</p></td></tr><tr><td></td><td>Encoding and Fingerprint</td><td><p>SHA256(23:59:59.123)|Base64</p><p>BnU8F5mhlQb4fHQe8jEFugx1K40y7SG/AOhrugFk6+s=</p></td></tr><tr><td></td><td><p>Location</p><p>(TXID, output #1)</p></td><td><a href="https://whatsonchain.com/tx/17a728b985d3ea1baa99bc7c2924384eb9493ccd6324c6cf95ccb5d8d3047f34">17a728b985d3ea1baa99bc7c2924384eb9493ccd6324c6cf95ccb5d8d3047f34</a></td></tr><tr><td>3.2</td><td>File Contents</td><td><p>Ticket3</p><p>City: Florence</p></td></tr><tr><td></td><td>Encoding and Fingerprint</td><td><p>SHA256(23:59:59.123)|Base64</p><p>Eav3xiiP56d/vRnWopYCqXqBKoXZEMkwG8A59BVzwHw=</p></td></tr><tr><td></td><td><p>Location</p><p>(TXID, output #1)</p></td><td><a href="https://whatsonchain.com/tx/832604ec7c5bd4f0ab883193ec6ffa19b86ddc000510d7c44deafb2dc5e5d3fd">832604ec7c5bd4f0ab883193ec6ffa19b86ddc000510d7c44deafb2dc5e5d3fd</a></td></tr><tr><td>3.3</td><td>File Contents</td><td><p>Ticket4</p><p>Pet: Timmy</p></td></tr><tr><td></td><td>Encoding and Fingerprint</td><td><p>SHA256(23:59:59.123)|Base64</p><p>PEFDAd5f4vpmgRySKY492zv+3NXYN4FO+2VSkKNbKX8=</p></td></tr><tr><td></td><td><p>Location</p><p>(TXID, output #1)</p></td><td><a href="https://whatsonchain.com/tx/94788398123ba546d49368d158a3bb5e7c3eaa18f14e3ebf8451cd15d955990e">94788398123ba546d49368d158a3bb5e7c3eaa18f14e3ebf8451cd15d955990e</a></td></tr><tr><td>4</td><td>File Contents</td><td>Random Selector</td></tr><tr><td></td><td>Encoding and Fingerprint</td><td>-</td></tr><tr><td></td><td><p>Location</p><p>(TXID, output #1)</p></td><td><a href="https://whatsonchain.com/tx/2a0b8764cf5df2899d8c4d7e0670efc028afed1ed2f98aebbc8ad150d2df6065">2a0b8764cf5df2899d8c4d7e0670efc028afed1ed2f98aebbc8ad150d2df6065</a></td></tr><tr><td>5</td><td>File Contents</td><td><p>Winner is picked from 2 LSB of random selector location. 00=>Ticket1, 01=>Ticket2, 10=>Ticket3, 11=>Ticket4</p><p>Random location is: 2a0b8764cf5df2899d8c4d7e0670efc028afed1ed2f98aebbc8ad150d2df6065</p><p>Last 2 bits are: 01</p><p>Winner is: Ticket2</p></td></tr><tr><td></td><td>Encoding and Fingerprint</td><td>-</td></tr><tr><td></td><td><p>Location</p><p>(TXID, output #1)</p></td><td><a href="https://whatsonchain.com/tx/aefaf50833866f61fd8afe1daf3898d50042c51c036035fb30fe4465c9ead066">aefaf50833866f61fd8afe1daf3898d50042c51c036035fb30fe4465c9ead066</a></td></tr><tr><td>6</td><td>File Contents</td><td>-</td></tr><tr><td></td><td>Encoding and Fingerprint</td><td>-</td></tr><tr><td></td><td><p>Location</p><p>(TXID, output #1)</p></td><td><a href="https://whatsonchain.com/tx/da85370bfbc1dc144471229c2a9c1c7f49e8c5c50d1ec66364c11028cee5fd74">da85370bfbc1dc144471229c2a9c1c7f49e8c5c50d1ec66364c11028cee5fd74</a></td></tr></tbody></table>


---

# 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.teranode.group/nchain-event/linked-records/use-cases/random-prize-draw.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.
