A lottery smart contract used to store lotteries, tickets, rounds. Allow users to buy tickets and claim rewards. Uses a special algorithm to get a random number instead of the traditional random and lottery functions
Before being able to run any command, you need to create a .env
file and set a BIP-39 compatible mnemonic as an
environment variable. You can follow the example in .env.example
. If you don't already have a mnemonic, you can use
this website to generate one.
Then, proceed with installing dependencies:
$ yarn install
Compile the smart contracts with Hardhat:
$ yarn compile
Compile the smart contracts and generate TypeChain bindings:
$ yarn typechain
Run the tests with Hardhat:
$ yarn test
Lint the Solidity code:
$ yarn lint:sol
Lint the TypeScript code:
$ yarn lint:ts
Generate the code coverage report:
$ yarn coverage
This project needs contract QulotLottery to operate. Other contracts you can customize or replace depending on the purpose of use:
Contract | Description |
---|---|
QulotLottery | Contract used to store lotteries, tickets, rounds. Allow users to buy tickets and claim rewards |
ChainLinkRandomNumberGenerator | Contract used to get random numbers from ChainLink VRF |
QulotAutomationTrigger | Contract used to schedule call QulotLottery |
$ yarn deploy:goerli
QulotLottery is a contract used to store lotteries, tickets, rounds. Allow users to buy tickets and claim rewards:
Deploy and verifying deployed contracts:
$ npx hardhat deploy:QulotLottery --network sepolia
First initialization for smart contract:
$ npx hardhat init:QulotLottery \
--network sepolia \
--address <deployed-address> \
--random <deployed-random-generator-address> \
--automation <deployed-automation-trigger-address>
ChainLinkRandomNumberGenerator is a contract used to get random numbers from ChainLink VRF:
Deploy and verifying deployed contracts:
$ npx hardhat deploy:ChainLinkRandomNumberGenerator --network sepolia
First initialization for smart contract:
$ npx hardhat init:ChainLinkRandomNumberGenerator \
--network sepolia \
--address <deployed-address> \
--qulot <qulot-lottery-address>
QulotAutomationTrigger is a duty contract to call the functions of QulotLottery like Open, Close, Draw, reward in a cron schedule setup:
This contract implemented the AutomationCompatibleInterface interface of ChainLink Automation.
Deploy and verifying deployed contracts:
$ npx hardhat deploy:QulotAutomationTrigger --network sepolia
First initialization for smart contract:
$ npx hardhat init:QulotAutomationTrigger \
--network sepolia \
--address <deployed-address> \
--qulot <qulot-lottery-address>