Skip to content

A React-based decentralized application using Ethereum, Ethers.js, and Solidity smart contracts for secure and transparent voting

Notifications You must be signed in to change notification settings

iuliastaci/StudentVoteDApp

Repository files navigation

StudentVoteDApp

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.

Features

  • 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.

Prerequisites

Make sure you have the following installed:

  1. Node.js: Download
  2. MetaMask Wallet: Download
  3. Hardhat: Installed via npm.
  4. Ethereum Test Tokens: For testing on Sepolia.

Setup Instructions

  1. Clone the repository
git clone https://github.com/iuliastaci/StudentVoteDApp.git
cd StudentVoteDApp
  1. Install Dependencies
npm install
  1. Start Local Blockchain (Hardhat) Open a new terminal and run:
npx hardhat node
  1. Deploy Smart Contracts In another terminal, deploy the contracts to Sepolia:
npx hardhat run scripts/deploy.js --network sepolia
  1. Connect frontend to Smart Contract
  • Update config.js with the contracts addresses and ABI from the deployment output.
  1. Start the frontend Run the app in development mode:
cd frontend
npm start

Running Tests

  • 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.

Usage

  1. Open the Application Navigate to https://localhost:3000 in your browser.

  2. Connect MetaMask Connect your MetaMask wallet to interact with the app.

  3. Admin Features

  • Add candidates through the admin interface.
  • Declare the winner after the voting period ends.
  1. Vote Cast votes and view live updates.

  2. View Winner Once voting concludes, view the declared winner.

About

A React-based decentralized application using Ethereum, Ethers.js, and Solidity smart contracts for secure and transparent voting

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published