# 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
