It is a decentralized app hosted on Goerli Testnet built with Brownie Framework and Web3.py Library.
- The contract owner starts the lottery
- Gamblers can enter Lottery with ETH based on USD
- The contract owner will choose when the lottery is over
- A winner is selected randomly, and he gets to win all the ether in the contract
In order to compile and deploy the contracts locally or on a testnet, you need to have Ganache and Metamask
Run this command to install dependencies:
pip3 install eth-brownie python-dotenv pytest
For me, I had to install a virtual environment before installing dependencies; check out this link for more details
To compile the contracts, simply run this command:
brownie compile
Before deploying the contract, you first have to make sure to fill the .env file. Check .env.example
run this command:
ganache-cli
and then in another terminal, run this command
brownie run scripts/deploy_lottery.py
Here is the result of deploying the contract locally
brownie run scripts/deploy_lottery.py --network goerli
Deploying the contract on a Testnet takes more time than deploying it locally so be patient.
Here is the result of Deploying the contract on Goerli, you can verify it on etherscan
Copy and paste the content of contracts/Lottery.sol in RemixIDE and play with it
To test the functionalities of our smart contract, you can first do that manually by going to scripts/deploy_lottery.py and uncomment the method calls, as shown in the screenshot below
and run the command
brownie run scripts/deploy_lottery.py --network goerli
Locally, end_lottery() and pick_winner() won't work because we are using contract deployed on the blockchain and for the VRFV2Wrapper there are no current mocks that we can use
Unit Tests will only run on a development local blockchain with this command
brownie test -s
Integration Tests will only run on a Testnet with this command
brownie test -s --network goerli