This project is a decentralized voting platform built on the Ethereum blockchain, designed to ensure transparency, security, and immutability in the voting process.
<br>
- Problem Statement
- Idea / Solution
- Dependencies / Limitations
- Installation
- Usage
- Technology Stack
- Authors
- Acknowledgments
In traditional voting systems, concerns about security, transparency, and trustworthiness have often arisen. Issues such as voter fraud, manipulation of results, and lack of transparency can undermine the legitimacy of an election. Additionally, centralized systems are vulnerable to cyber-attacks and data breaches, posing a significant risk to the integrity of the voting process.
This project proposes a decentralized voting platform leveraging blockchain technology to address the challenges of traditional voting systems. By recording votes on the Ethereum blockchain, the system ensures that every vote is securely recorded, immutable, and transparent to all stakeholders. The platform integrates secure voter authentication using JWT tokens and manages voter data using a MySQL database hosted on Microsoft Azure. The decentralized nature of blockchain technology, combined with secure authentication and cloud-hosted data management, offers a robust and trustworthy solution for modern elections.
- Python 3.9+
- FastAPI: Web framework for building APIs.
- PyJWT: For generating and verifying JWT tokens.
- mysql-connector-python: MySQL database connector.
- dotenv: For managing environment variables.
- Node.js & npm: For managing dependencies and running scripts.
- Express: Server to handle static files and authentication.
- MetaMask: Ethereum wallet integration for blockchain interaction.
- Truffle: Development framework for Ethereum.
- Web3.js: JavaScript library for interacting with the Ethereum blockchain.
- Microsoft Azure:
- Azure MySQL Database: To store voter information.
- Azure App Service: To host the FastAPI backend.
- Vercel/Netlify (Optional): For hosting the frontend.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
What things you need to install the software and how to install them.
Give examples
-
Open a terminal.
-
Clone the repository by using the command:
git clone https://github.com/AdityaSeth777/blockchain-voting.git
-
Download and install Ganache.
-
Create a workspace named development in Ganache. In the Truffle projects section, add
truffle-config.js
by clicking theADD PROJECT
button. -
Download the Metamask extension for your browser.
-
Create a wallet (if you don't have one), then import accounts from Ganache.
-
Add a network to Metamask:
- Network Name: Localhost 7575
- RPC URL:
http://localhost:7545
- Chain ID: 1337
- Currency Symbol: ETH
-
Open MySQL and create a database named voter_db. (DO NOT USE XAMPP)
-
In the
voter_db
database, create a new table named voters with the following structure and add some values:CREATE TABLE voters ( voter_id VARCHAR(36) PRIMARY KEY NOT NULL, role ENUM('admin', 'user') NOT NULL, password VARCHAR(255) NOT NULL );
Sample Table:
+--------------------------------------+-------+-----------+ | voter_id | role | password | +--------------------------------------+-------+-----------+ | | | | +--------------------------------------+-------+-----------+
-
Install Truffle globally:
npm install -g truffle
-
Navigate to the root directory of the repository and install Node.js modules:
npm install
-
Install Python dependencies:
pip install fastapi mysql-connector-python pydantic python-dotenv uvicorn uvicorn[standard] PyJWT
Note: Update the database credentials in the
./db/.env
file.
-
Open a terminal in the project directory.
-
Open Ganache and its development workspace.
-
Open a terminal in the project's root directory and run the command:
truffle console
Then, compile the smart contracts with the command:
compile
Exit the Truffle console.
-
Bundle
app.js
with Browserify:browserify ./src/js/app.js -o ./src/dist/app.bundle.js
-
Start the Node.js server:
node index.js
-
Navigate to the
db
folder in another terminal:cd db
Then, start the database server with the following command:
uvicorn main:app --reload --host 127.0.0.1
-
In a new terminal, migrate the Truffle contract to the local blockchain:
truffle migrate
You're all set! The Voting app should be up and running now at http://localhost:8080/.
- Aditi Ghosh
- Ayash Bera
- Aditya Seth
- Rudranil Chowdhury
- Hat tip to anyone whose code was used
- Inspiration
- References