> For the complete documentation index, see [llms.txt](https://docs.delot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.delot.io/lottery-game/fully-automatic-system.md).

# Fully Automatic System

[Chainlink Automation](https://docs.chain.link/chainlink-automation/introduction) is used as the solution to make lottery game can run endlessly.

Basically, Lottery Smart Contract is [Keeper-compatible](https://docs.chain.link/chainlink-automation/compatible-contracts).\
\
-> [Upkeep on BSC](https://automation.chain.link/bsc/43822477634734146326080467616334561044134124446829926591638976391798083138274)

“performUpkeep” function in Lottery Smart Contract is designed to:

* Change state of a round: Start -> Active -> End
* Round state is Start: proceed to transfer tokens from Auto Pool to Lottery Pool based on settings in Auto Pool of players.
* Round state is End:
  * Recalculate tickets of players, reset Hold Tickets to zero if they do not hold enough token as recognized in the first deposit.
  * Call to [Chainlink VRF](https://docs.chain.link/docs/chainlink-vrf/) to get randomness numbers
  * Find winners based on random numbers
  * Reward the prize winners
  * Initialize new round


---

# 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:

```
GET https://docs.delot.io/lottery-game/fully-automatic-system.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.
