Implement a lottery contract that meets the following conditions:
- New lotteries must be created through the factory. Creation is possible only by the owner of the factory. The factory must keep the addresses of all lotteries created by it.
- The lottery contract must have 3 states: NEW, IN_PROGRESS, FINALIZING_RESULTS, FINISHED. Each of these states is determined by a certain period of time that is specified when creating a contract.
- It is impossible to buy tickets in the NEW state.
- In the IN_PROGRESS state, users can purchase tickets. Each user can buy up to 10 tickets. All 10 tickets can be purchased in one transaction.
- Each ticket has a fixed price in coins (ETH). The price is specified when creating a contract.
- For each ticket the user receives one random number from 1 to 1000
- In the FINALIZING_RESULTS state, the lottery results are calculated. The transition to the next state is possible only after complete processing of the results.
- After the contract becomes FINISHED, the factory owner has the opportunity to withdraw exactly 10% of the funds collected.
- The remaining funds should be divided between the users who dropped the most random number.
External part of oracle is not included in the task
Will be a plus:
- Configure the development environment (Truffle, Hardhat, etc).
- Cover the functionality of the factory and lottery with tests.