StudentVoteDApp is a decentralized application (DApp) for conducting student representative elections. Built using React, Ethereum, Ethers.js and Solidity, it ensures secure and transparent voting. It uses Hardhat as the local Ethereum development network and Sepolia as the test network.
- Connect wallet via Metamask.
- View candidate list with current vote counts.
- Add new candidates (admin functionality).
- Cast votes securely for a candidate.
- Declare the winner after the voting period ends (admin functionality).
- View the winner once voting has concluded.
- Fetch real-time updates of candidates and votes from the blockchain.
Make sure you have the following installed:
- Node.js: Download
- MetaMask Wallet: Download
- Hardhat: Installed via npm.
- Ethereum Test Tokens: For testing on Sepolia.
- Clone the repository
git clone https://github.com/iuliastaci/StudentVoteDApp.git
cd StudentVoteDApp
- Install Dependencies
npm install
- Start Local Blockchain (Hardhat) Open a new terminal and run:
npx hardhat node
- Deploy Smart Contracts In another terminal, deploy the contracts to Sepolia:
npx hardhat run scripts/deploy.js --network sepolia
- Connect frontend to Smart Contract
- Update
config.js
with the contracts addresses and ABI from the deployment output.
- Start the frontend Run the app in development mode:
cd frontend
npm start
- Tests for the smart contracts are located in the
test
folder. - Make sure your Hardhat node is running (
npx hardhat node
) and execute:
npx hardhat test
- The test results will be displayed in the terminal, detailing the passed and failed cases.
-
Open the Application Navigate to
https://localhost:3000
in your browser. -
Connect MetaMask Connect your MetaMask wallet to interact with the app.
-
Admin Features
- Add candidates through the admin interface.
- Declare the winner after the voting period ends.
-
Vote Cast votes and view live updates.
-
View Winner Once voting concludes, view the declared winner.