> 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/chainlink-integration.md).

# Chainlink Integration

[Visit Chainlink](https://chain.link)

Leet Lotto relies on Chainlink services for tamper-proof randomness and autonomous upkeep.

### Verifiable Randomness

```solidity
// ⚠️ Simplified example
function drawWinner(uint256 lottoId) external onlyUpkeep {
    bytes32 requestId = VRFCoordinator.requestRandomWords(
        keyHash,
        subscriptionId,
        3,          // confirmations
        200000,     // gasLimit
        1           // words
    );
    vrfRequests[requestId] = lottoId;
}
```

* **Chainlink VRF** returns a random value used to pick the winning ticket index.
* Anyone can verify the randomness on-chain.

### Automation / Upkeep

```solidity
// ⚠️ Simplified example
function checkUpkeep(bytes calldata) external view returns (bool, bytes memory) {
    bool isReady = block.timestamp >= closingTime && !winnerSelected;
    return (isReady, bytes(""));
}

function performUpkeep(bytes calldata) external {
    require(block.timestamp >= closingTime, "Lottery still open");
    _startVRFRequest();
}
```

* Draws trigger automatically when a lotto’s closing time hits.
* Removes human intervention and schedule risk.


---

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