This is my idea for a minimalistic Lottry Front End. The project assumes that you have the foundry-lottery project locally.
_NOTE: I've created this repo to be ran against the SEPOLIA MAINNET, so that you can get a better feel of how to enable Chainlink VRF and Upkeeps.
- git
- You'll know you've installed it right if you can run:
git --version
- You'll know you've installed it right if you can run:
- Metamask
- This is a browser extension that lets you interact with the blockchain.
- Clone the repo
git clone https://github.com/Welith/foundry-lottery-html
cd foundry-lottery-html
- Run the file.
You can usually just double click the file to "run it in the browser". Or you can right click the file in your VSCode and run "open with live server".
And you should see a small button that says "connect".
Hit it, and you should see metamask pop up.
If you want to join the lottery follow the steps below:
Make sure you have the following installed:
- You'll need to open up a second terminal and run:
git clone https://github.com/Welith/foundry-lottery
cd foundry-lottery
make build
make deploy ARGS="--network sepolia" (supposed you've got all the requirements from the lottery repo README!)
This will deploy a contract to SEPOLIA.
- Update your
constants.js
with the new contract address.
In your constants.js
file, update the variable contractAddress
with the address of the deployed "Lottery" contract. Check it out in the lottery depoyment terminal output.
- Connect your metamask to your local hardhat blockchain.
PLEASE USE A METAMASK ACCOUNT THAT ISNT ASSOCIATED WITH ANY REAL MONEY. I usually use a few different browser profiles to separate my metamasks easily.
-
Refresh the front end, input an amount in the text box, and hit
Enter Lottery
button after connecting. -
In order to enable the lottery automation, you will need to create a chainlink VRF, then create a subscription, fund it, and in the end add your deployed contract as a consumer.
-
Finally, you will need to create an Upkeep, which will draw the lucky winner.