Skip to content

NICxKMS/Decentralized_Voting_App

Repository files navigation

Decentralized Voting App

A blockchain-based electronic voting system built with Ethereum smart contracts and Next.js.

Badges

MIT License Node.js Version Solidity Version

Features

  • Secure and transparent voting using blockchain technology
  • User registration and authentication
  • Administrative panel to manage elections and candidates
  • Real-time vote counting and results display
  • Mobile-friendly responsive UI built with Chakra UI

Technology Stack

Blockchain

Click to view
  • Ethereum Smart Contracts (Solidity)
  • Hardhat - Development environment

Frontend

Click to view
  • Next.js - React framework
  • Chakra UI - Component library

Web3

Click to view
  • ethers.js - Ethereum web client library

Local Development Setup

  1. Clone the repository:
    git clone https://github.com/NICxKMS/Decentralized_Voting_App.git
    cd Decentralized_Voting_App
  2. Install dependencies:
    npm install
  3. Start local Hardhat node:
    npx hardhat node
  4. Deploy the contract:
    npx hardhat run scripts/deploy.js --network localhost
  5. Configure environment variables:
    NEXT_PUBLIC_CONTRACT_ADDRESS=your_contract_address
  6. Start development server:
    npm run dev

Open http://localhost:3000 to view the application.

Testing

Run the test suite:

npx hardhat test

With gas reporting:

REPORT_GAS=true npx hardhat test

Project Structure


Decentralized_Voting_App/
├── contracts/           # Smart contract source code
├── src/
│   ├── artifacts/      # Contract ABIs and deployment info
│   ├── components/     # React components
│   ├── context/        # React context providers
│   ├── hooks/          # Custom React hooks
│   ├── pages/          # Next.js pages and API routes
│   └── utils/          # Helper utilities
├── test/               # Contract test files
└── hardhat.config.js   # Hardhat configuration

Interactive Demo

Check out our interactive demo! Click the button below to explore:

Launch Demo

Contributing

Pull requests are welcome! Please read our contributing guidelines first.

License

This project is licensed under the MIT License.

Credits

Designed and Developed by Nikhil

View project on GitHub.

API Endpoints

Here are some of the key API endpoints for interacting with the Decentralized Voting App:

Endpoint Description Method
/api/votes Submit a vote POST
/api/results Get current vote results GET
/api/register Register a new user POST

Tips & Tricks

Hover over the sections below for additional tips:

  • Deploying Smart Contracts
  • Using Chakra UI

FAQ

What is Ethereum Smart Contract?

Ethereum Smart Contracts are self-executing contracts with the terms of the agreement directly written into code. It runs on the Ethereum blockchain and ensures secure, transparent transactions.

How do I configure the environment variables?

To configure the environment variables, create a .env file in the root directory of the project and add your contract address like so: NEXT_PUBLIC_CONTRACT_ADDRESS=your_contract_address

About

Decentralized Voting App using ethereum and Next.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors