Anish-U / BlockVote

A Blockchain based voting application using solidity, truffle and nodejs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project logo

BlockVote🗳️

A Blockchain based voting application using solidity, truffle and nodejs.


📝 Table of Contents


🧐 About

A democratic country is built on the foundations of elections. Election is one of the founding pillars of any democracy and hence it is imperative that this process is carried out in the most secure and transparent way. Existing voting systems are centralized in nature, are susceptibly to tampering, and have often raised suspicion among the common people.

So through this project, I aim to build a decentralized voting application where all voters will be able to register, cast their vote and personally verify these votes. In this project we have assumed that we are given with the database of voter, which have aadhaar and other credentials.


🏁 Getting Started

BlockVote web application uses node.js along with the express.js framework to develop the server and mongoDB as database and mongoose as object data modeling library. For the blockchain aspect, we have used the ethereum blockchain to deploy the smart contracts and web3.js library to interact with the ethereum node and the frontend. We have used Ganache and Truffle for creating a remote Blockchain environment.

Prerequisites

The following dependencies need to be installed.

  - node.js
  - npm
  - mongodb / mongodb atlas
  - web3.js
  - Ganache
  - Truffle

Installing ⬇️

Retrieve the project (clone the repository using the command)

  git clone https://github.com/Anish-U/BlockVote.git

After cloning the repository, navigate into the directory and run the following command to install all the dependencies

  npm install

Setting up database📦 and env

Setup the environment variables by creating .env file in root directory

  PORT = 3000
  DB_URI = "mongodb://localhost:27017/BlockVote"
  GANACHE_URI = "http://localhost:7545"
  SESSION_SECRET = "SESSION_SECRET_KEY_HERE"
  JWT_KEY = "JWT_SECRET_KEY_HERE"

Add few voters and one admin into database as we assume that the application is already given with the voter details.

  // MongoDB CLI
  
  db.voters.insertOne(
    {
      aadhaar: "234567892345", 
      name: "Ummenthala Anish", 
      password:"$2a$12$s1Ue2JOpIq2Vk/H3HjDFgeNtvxRM4tGBCyZr6Nw4SOIf/75LISEm2", 
      gender:"male"
    }
  )

  db.admins.insertOne(
    {
      username: "admin", 
      password:"$2a$12$s1Ue2JOpIq2Vk/H3HjDFgeNtvxRM4tGBCyZr6Nw4SOIf/75LISEm2", 
    }
  )

Note: Password hash can be generated at Bcrypt

Setting up Blockchain⛓️ environment

Run ganache application in the background

Open the terminal and compile the Smart Contract to create the ABI of the smart contract and network id.

After compiling we need to migrate the contracts.

  truffle compile
  truffle migrate --reset

🚀 Deployment

In another terminal, run the command

  npm run devStart (or) node server.js

When the command runs successfully. Go to localhost:3000 there you will land on the home page of the project.


⛏️ Built Using

  • MongoDB - Database
  • Express - Server Framework
  • NodeJs - Server Environment
  • Solidity - Used to develop Smart contracts
  • Truffle - Development environment, testing framework for blockchains
  • Ganache - Personal blockchain for rapid Ethereum distributed application development
  • Web3JS - Library that allow you to interact with a local or remote ethereum node.

📸 Screenshots

Home Page

Admin: Login Page

Admin: Dashboard

Admin: Add Candidate

Admin: View Candidates

Admin: Add Candidate Error

Voter: Login Page

Voter: Dashboard

Voter: Phone Number Registration

Voter: Ethereum Account Registration

Voter: Voting

Voter: Voting Error Page

View Results

Results Error

About

A Blockchain based voting application using solidity, truffle and nodejs.


Languages

Language:CSS 68.5%Language:EJS 18.5%Language:JavaScript 12.1%Language:Solidity 0.9%