A blockchain-based electronic voting system built with Ethereum smart contracts and Next.js.
- 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
Click to view
- Ethereum Smart Contracts (Solidity)
- Hardhat - Development environment
Click to view
- Next.js - React framework
- Chakra UI - Component library
Click to view
- ethers.js - Ethereum web client library
- Clone the repository:
git clone https://github.com/NICxKMS/Decentralized_Voting_App.git cd Decentralized_Voting_App - Install dependencies:
npm install - Start local Hardhat node:
npx hardhat node - Deploy the contract:
npx hardhat run scripts/deploy.js --network localhost - Configure environment variables:
NEXT_PUBLIC_CONTRACT_ADDRESS=your_contract_address - Start development server:
npm run dev
Open http://localhost:3000 to view the application.
Run the test suite:
npx hardhat testWith gas reporting:
REPORT_GAS=true npx hardhat test
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
Check out our interactive demo! Click the button below to explore:
Launch DemoPull requests are welcome! Please read our contributing guidelines first.
This project is licensed under the MIT License.
Designed and Developed by Nikhil
View project on GitHub.
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 |
Hover over the sections below for additional tips:
- Deploying Smart Contracts
- Using Chakra UI
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