> For the complete documentation index, see [llms.txt](https://whitepaper.gmr.center/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whitepaper.gmr.center/gmr-center/leet-lotto/prize-security.md).

# 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
