Skip to content

A lottery smart contract used to store lotteries, tickets, rounds. Allow users to buy tickets and claim rewards.

License

Notifications You must be signed in to change notification settings

qulot/qulot-smart-contracts

Repository files navigation

qulot-smart-contracts

Description

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

Usage

Pre Requisites

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

Compile the smart contracts with Hardhat:

$ yarn compile

TypeChain

Compile the smart contracts and generate TypeChain bindings:

$ yarn typechain

Test

Run the tests with Hardhat:

$ yarn test

Lint Solidity

Lint the Solidity code:

$ yarn lint:sol

Lint TypeScript

Lint the TypeScript code:

$ yarn lint:ts

Coverage

Generate the code coverage report:

$ yarn coverage

Contracts

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 (required)

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 (optional)

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 (optional)

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>

About

A lottery smart contract used to store lotteries, tickets, rounds. Allow users to buy tickets and claim rewards.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published