# Prize Security

Security is welded into every layer so winners get paid and funds stay safe.

### Contract Level

| Measure                       | Detail                                                                                                                         |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| **Audited Logic**             | External audit covering all VRF, Automation and OpenZeppelin contracts, related to ticketing, prize draws and fund management. |
| **Re-entrancy Guards**        | Prevent double-spend exploits                                                                                                  |
| **Proper Nonce/Gas Handling** | Protects against replay and under-priced gas attacks                                                                           |

### Randomness & Fairness

* Chainlink VRF ensures random numbers no single party can predict or tamper with.
* VRF proof is stored on-chain so anyone can verify the winning ticket calculation.

### Prize Distribution

```solidity
// ⚠️ Simplified example
function _distribute(
    PrizeType prizeType,
    address recipient,
    uint256 amount,
    address erc20Token,
    address nftAddress,
    uint256 tokenId
) internal nonReentrant {
    if (prizeType == PrizeType.CURRENCY) {
        Address.sendValue(payable(recipient), amount);
    } else if (prizeType == PrizeType.ERC20) {
        SafeERC20.safeTransfer(IERC20(erc20Token), recipient, amount);
    } else {
        IERC721(nftAddress).safeTransferFrom(address(this), recipient, tokenId);
    }
}
```

* Currency and tokens transfer automatically on winner confirmation.
* NFTs delivered via `safeTransferFrom` to guarantee receipt.

### Ongoing Monitoring

* **Upkeep Alerts** via Chainlink keepers
* **Sentry** and **Datadog** watch contract events and subgraph health


---

# 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://whitepaper.gmr.center/gmr-center/leet-lotto/prize-security.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.
