This project is a simple voting system where people can vote whether they put their cereal first or milk first. It is built on React.js, Solidity and Hardhat. The frontend is deployed on Vercel while the "backend" (which is essentially the smart contract) is deployed using Alchemy.
- Connect with MetaMask: Users are able to interact with this service by connecting their MetaMask wallet
- Fetch Votes: Allows users to see what are the votes currently
- Vote: Allows users to vote for themselves
You require the following:
- A MetaMask Wallet - https://metamask.io/download/
- Sepolia ETH currency - get some free Sepolia ETH here - https://sepoliafaucet.com/
Once done, go to the dApp site at https://cereal-milk-voting-dapp.vercel.app/, connect your wallet, and you can vote!
You can see the smart contract that has been deployed here - https://sepolia.etherscan.io/address/0x7ECa4b21F31883B9C7EcE9b06f82062be6AEaD01
- Clone this repo into your local machine
- Run
npm install
to install all dependencies
The next part depends whether you want to deploy the smart contract on your local machine or on the blockchain.
- Run
npx hardhat node
to start your own local blockchain - Run
npx hardhat run scripts/deploy.js --network localhost
to deploy the smart contract on that local blockchain - Import one of the provided accounts into your MetaMask
- Rename the
env
file to.env
and add your own Alchemy API key and the private key of a wallet with Sepolia ETH currency. 1a. Create your own Alchemy account here - https://dashboard.alchemy.com/ 2a. Get some free Sepolia ETH here - https://sepoliafaucet.com/ - Run
npx hardhat run scripts/deploy.js --network sepolia
Once either of the above is done, start the frontend by running npm run start
.
If you wish to re-compile the smart contract yourself, first run npx hardhat clean
and then npx hardhat compile
.
Testing was done using Chai. To run a test on the smart contract, do npx hardhat test
.
This project was done with the help of SMU Blockchain and also this tutorial https://www.youtube.com/watch?v=nNUpA0d6CFo.