



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.
- JWT for secure voter authentication and authorization.
- 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.
- Node.js (version 18.14.0)
- Metamask
- Python (version 3.9)
- FastAPI
- MySQL Database (port 3306)
-
Clone the repository:
git clone https://github.com/akanksha509/Decentralized-Voting-System-Using-Ethereum-Blockchain.git
-
Download and install Ganache.
-
Create a workspace named
development
in Ganache, then addtruffle-config.js
in the Truffle projects section by clicking ADD PROJECT. -
Install Metamask in your browser and import the Ganache accounts into Metamask.
-
Add a network to Metamask:
- Network Name: Localhost 7575
- RPC URL: http://localhost:7545
- Chain ID: 1337
- Currency Symbol: ETH
-
Create a MySQL database named
voter_db
(avoid using XAMPP). Inside this database, create a tablevoters
:CREATE TABLE voters ( voter_id VARCHAR(36) PRIMARY KEY NOT NULL, role ENUM('admin', 'user') NOT NULL, password VARCHAR(255) NOT NULL );
-
Install Truffle globally:
npm install -g truffle
-
Install Node.js dependencies (in the project folder):
npm install
-
Install Python dependencies:
pip install fastapi mysql-connector-python pydantic python-dotenv uvicorn uvicorn[standard] PyJWT
Note: Update the database credentials in
./Database_API/.env
with your MySQL username, password, etc.
-
Open Ganache and select the
development
workspace. -
Open a terminal in the project directory and enter the Truffle console:
truffle console
-
Compile the smart contracts:
compile
Then exit the console by typing
.exit
or pressingCtrl + C
. -
Bundle
app.js
with Browserify:browserify ./src/js/app.js -o ./src/dist/app.bundle.js
-
Start the Node.js server:
node index.js
-
Open another terminal, navigate to the
Database_API
folder:cd Database_API
-
Start the FastAPI server:
uvicorn main:app --reload --host 127.0.0.1
-
In a new terminal, migrate the Truffle contract to the local blockchain:
truffle migrate
-
Access the Voting app at http://localhost:8080/.
blockchain-voting-dapp/
├── build/
│ └── contracts/
│ ├── Migrations.json
│ └── Voting.json
├── contracts/
│ ├── Migrations.sol
│ └── Voting.sol
├── Database_API/
│ └── main.py
├── migrations/
│ └── 1_initial_migration.js
├── node_modules/
├── public/
│ └── favicon.ico
├── src/
│ ├── assets/
│ │ └── eth5.jpg
│ ├── css/
│ │ ├── admin.css
│ │ ├── index.css
│ │ └── login.css
│ ├── dist/
│ │ ├── app.bundle.js
│ │ └── login.bundle.js
│ ├── html/
│ │ ├── admin.html
│ │ ├── index.html
│ │ └── login.html
│ └── js/
│ ├── app.js
│ └── login.js
├── index.js
├── package.json
├── package-lock.json
├── truffle-config.js
└── README.md
This project is licensed under the MIT License.
⭐ If you like this project, please give it a star!

Leave a Reply