Lotterex is a simple smart contract that allows anyone to deploy a Lottery smart contract, and allow others to join the lottery. Once there are at least 3 people in the Lottery, the deployer of the smart contract can randomly pick the winner and send them the prize.
I needed to submit a project strictly following the requirements for my BADV (Introduction to Blockchain Application Development) submission.
The Truffle project which contains the smart contract and tests
The NextJS project containing the UI to interact with the smart contract
- Create Lottery
- Lottery Name
- Lottery Price
- Enter Lottery
- Leave Lottery
- Lottery Manager Controls
- Pick random winner for Lottery
- Close Lottery
- Developer page to call smart contract functions directly
In the Truffle project, setup the truffle-config.js file, then build it with the command
$ pnpm buildMake sure the folder contracts is generated in web-next-lotterex/src
Then you can run the following command in the NextJS project
$ pnpm devThis example project using React from Truffle helped me out the most.
The Lotterex smart contract is tested with Truffle Suite. To run the tests, run the following command in the Truffle project
$ pnpm test