Decentralized Voting System
A decentralized voting system using Ethereum blockchain for secure and transparent elections, with features like user authentication and real-time result tracking.
- Implements JWT for secure voter authentication and authorization. - Utilizes Ethereum blockchain for tamper-proof and transparent voting records. - Removes the need for intermediaries, ensuring a trustless voting process. - Admin panel to manage candidates, set voting dates, and monitor results. - Intuitive UI for voters to cast votes and view candidate information. The project is written primarily in JavaScript, distributed under the MIT License license, first published in 2023. Key topics include: blockchain, blockchain-voting, blockchain-voting-system, decentralization, decentralized-applications.
Decentralized-Voting-System-Using-Ethereum-Blockchain
The Decentralized Voting System using Ethereum Blockchain is a secure and transparent solution for conducting elections. Leveraging Ethereum's blockchain technology, this system ensures tamper-proof voting records, enabling users to cast their votes remotely while maintaining anonymity and preventing fraud. Explore this innovative project for trustworthy and decentralized voting processes.
For a cool demo of this project watch this YouTube video.
For more details checkout Project Report.
PS: This project is not maintained anymore.
Features
- Implements JWT for secure voter authentication and authorization.
- Utilizes Ethereum blockchain for tamper-proof and transparent voting records.
- Removes the need for intermediaries, ensuring a trustless voting process.
- Admin panel to manage candidates, set voting dates, and monitor results.
- Intuitive UI for voters to cast votes and view candidate information.
Requirements
- Node.js (version โ 18.14.0)
- Metamask
- Python (version โ 3.9)
- FastAPI
- MySQL Database (port โ 3306)
Screenshots



Installation
-
Open a terminal.
-
Clone the repository by using the command
git clone https://github.com/Krish-Depani/Decentralized-Voting-System-Using-Ethereum-Blockchain.git -
Download and install Ganache.
-
Create a workspace named <b>developement</b>, in the truffle projects section add
truffle-config.jsby clickingADD PROJECTbutton. -
Download Metamask extension for the browser.
-
Now create wallet (if you don't have one), then import accounts from ganache.
-
Add network to the metamask. ( Network name - Localhost 7575, RPC URl - http://localhost:7545, Chain ID - 1337, Currency symbol - ETH)
-
Open MySQL and create database named <b>voter_db</b>. (DON'T USE XAMPP)
-
In the database created, create new table named <b>voters</b> in the given format and add some values.
<br>CREATE TABLE voters ( voter_id VARCHAR(36) PRIMARY KEY NOT NULL, role ENUM('admin', 'user') NOT NULL, password VARCHAR(255) NOT NULL );+--------------------------------------+-------+-----------+ | voter_id | role | password | +--------------------------------------+-------+-----------+ | | | | +--------------------------------------+-------+-----------+ -
Install truffle globally
npm install -g truffle -
Go to the root directory of repo and install node modules
npm install -
Install python dependencies
pip install fastapi mysql-connector-python pydantic python-dotenv uvicorn uvicorn[standard] PyJWT
Usage
Note: Update the database credentials in the ./Database_API/.env file.
-
Open terminal at the project directory
-
Open Ganache and it's <b>development</b> workspace.
-
open terminal in project's root directory and run the command
truffle consolethen compile the smart contracts with command
compileexit the truffle console
-
Bundle app.js with browserify
browserify ./src/js/app.js -o ./src/dist/app.bundle.js -
Start the node server server
node index.js -
Navigate to
Database_APIfolder in another terminalcd Database_APIthen start the database server by following command
uvicorn main:app --reload --host 127.0.0.1 -
In a new terminal migrate the truffle contract to local blockchain
truffle migrate
You're all set! The Voting app should be up and running now at http://localhost:8080/.<br>
For more info about usage checkout YouTube video.
Code Structure
โโโ blockchain-voting-dapp # Root directory of the project.
โโโ build # Directory containing compiled contract artifacts.
| โโโ contracts
| โโโ Migrations.json
| โโโ Voting.json
โโโ contracts # Directory containing smart contract source code.
| โโโ 2_deploy_contracts.js
| โโโ Migrations.sol
| โโโ Voting.sol
โโโ Database_API # API code for database communication.
| โโโ main.py
โโโ migrations # Ethereum contract deployment scripts.
| โโโ 1_initial_migration.js
โโโ node_modules # Node.js modules and dependencies.
โโโ public # Public assets like favicon.
| โโโ favicon.ico
โโโ src
| โโโ assets # Project images.
| | โโโ eth5.jpg
| โโโ css # CSS stylesheets.
| | โโโ admin.css
| | โโโ index.css
| | โโโ login.css
| โโโ dist # Compiled JavaScript bundles.
| | โโโ app.bundle.js
| | โโโ login.bundle.js
| โโโ html # HTML templates.
| | โโโ admin.html
| | โโโ index.html
| | โโโ login.html
| โโโ js # JavaScript logic files.
| โโโ app.js
| โโโ login.js
โโโ index.js # Main entry point for Node.js application.
โโโ package.json # Node.js package configuration.
โโโ package-lock.json # Lockfile for package dependencies.
โโโ README.md # Project documentation.
โโโ truffle-config.js # Truffle configuration file.
License
The code in this repository is licensed under the MIT License. This means that you are free to use, modify, and distribute the code, as long as you include the original copyright and license notice. For more information about LICENSE please click here.
If you like this project, please give it a ๐.
Thank you ๐.
Contributors
Showing top 1 contributor by commit count.
