0% found this document useful (0 votes)
172 views

Mini Project

The document discusses developing a decentralized polling app using blockchain to enable secure public opinion polling. Public opinion polls are used to measure acceptance of issues but existing polling systems are vulnerable to security attacks. The proposed project aims to create a web application for users to create and vote in polls that will utilize blockchain for security and transparency.

Uploaded by

Vishnu Ram V
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
172 views

Mini Project

The document discusses developing a decentralized polling app using blockchain to enable secure public opinion polling. Public opinion polls are used to measure acceptance of issues but existing polling systems are vulnerable to security attacks. The proposed project aims to create a web application for users to create and vote in polls that will utilize blockchain for security and transparency.

Uploaded by

Vishnu Ram V
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

CLOUD-BASED DECENTRAILIZED POLLING APP

USING BLOCKCHAIN

A PROJECT REPORT

Submitted by

VISHNU RAM V

(210419104185)

SUDHARSAN S

(210419104167)

In partial fulfilment for the award of the degree

of

BACHELOR OF ENGINEERING

in

COMPUTER SCIENCE AND ENGINEERING

CHENNAI INSTITUTE OF TECHNOLOGY, KUNDRATHUR


CHENNAI-600069

ANNA UNIVERSITY: CHENNAI 600025


JUNE 2022
BONAFIDE CERTIFICATE

Certified that this project report “CLOUD BASED DECENTRALIZED


POLLING APP USING BLOCKCHAIN" is the bonafide work of “V VISHNU
RAM(210419104185) and S SUDHARSAN(210419104167)” who carried out the
project work under my supervision.

SIGNATURE SIGNATURE

I.XXXXXXX (Ph.D.), I.YYYYYYY (Ph.D.),

HEAD OF THE DEPARTMENT, SUPERVISOR,

ASSOCIATE PROFESSOR, ASSOCIATE PROFESSOR,

Department of Computer Science and Department of Computer Science and


Engineering, Engineering,

XXX College of Engineering, XXX College of Engineering,

Tamil Nadu – 605 100. Tamil Nadu – 605 100.

The project report submitted for the viva voce held on ………….

INTERNAL EXAMINER EXTERNAL EXAMINER


ACKNOWLEDGEMENT

I thank the almighty, for the blessings that have been showered upon me to
bring forth the success of the project. I would like to express my sincere gratitude
to our chairman Mr.I.XYYX, vice chairman Mr.I.Yyyyyyyy and our secretary
Mr.I.DDDDDD for providing us with an excellent infrastructure and necessary
resources to carry out this project and I extend my gratitude to ourprincipal Dr.
I.VVVVVVV, for his constant support to my work.

I also take this opportunity to express my sincere thanks to our vice


principal Dr.I.RHGRG and our dean-placement Prof.EFEJEF, who has
providedall the needful help for me in executing the project successfully.

I wish to express my thanks to our Head of the Department, Prof.I.FFFFF,


Ph.D., for her encouragement and support to complete this project. I express my
heartfelt gratitude to my guide Mr.I.Mmmmmm,Ph.D., Associate Professor,
Department of Computer Science and Engineering for his priceless guidance and
motivation which helped me to bring this project to a perfect shape who
encouraged me in each and every step of this project to complete it successfully.

I express our deep sense of thanks to all faculty members in my department for
their cooperation and interest shown at every stage of our endeavor in making a
project work success.

Last but not least, our sincere thanks to our lovely parents and friends who
had been the constant source of our strength throughout our life.

iii
ABSTRACT

We have been familiar with Peer-to-Peer communications in the Internet

for so long. But with the growing technologies, the security and resources on

these communications has been a major drawback. Blockchain is a technology

which supports the idea of a network managing its own security and resources.

Public opinion polling is a kind of survey used to measure degree of acceptance

of the people for a particular issue or topic. These polls must be created and

conducted in a secure way so that the polls remain unbiased from any kind of

malicious users. Since Blockchain can secure any kind of data transmission, it is

extremely useful for voting systems since the value of votes cannot be

compromised. We intend to create a web application which enables any user to

create a poll, which is then displayed to all the users. Any user can cast their

vote to any poll in the system and the final results are achieved in a transparent

manner using Blockchain behind the hood.

iv
TABLE OF CONTENTS
CHAPTER TITLE PAGE
NO NO
ABSTRACT iv
LIST OF FIGURES vii
LIST OF TABLES viii
LIST OF ABBREVIATION ix
1 INTRODUCTION 1
1.1 Scope of the project 2
1.2 Objective of the project 2
1.3 Review Summary 2
2 RELATED ARTICLES 3
2.1 Introduction 3
2.1 Introduction 3

2.2 Comparative Analysis on E-Voting System 3

2.3 Platform-Independent Secure Blockchain-Based 3


Voting
3 RELATED WORK 4
3.1 E-Voting 4
3.2 Decentralization 4
3.3 Blockchain 5
3.4 NEAR Protocol 6
3.5 Smart Contracts 6
3.6 Blockchain wallet 7
3.7 Meta Transactions 7

v
4 PROPOSED METHODOLOGY 10
4.1 Methodology 10

5 SYSTEM SPECIFICATION 14
5.1 Software Requirement 14
5.1.1 NodeJs 14
5.1.2 NPM 14
5.1.3 ReactJs 15
5.1.4 Solidity 15
5.1.5 Truffle Suite 15
5.1.6 Metamask 15

5.2 Hardware Requirement 16


5.3 Installation procedure 16
5.4 Smart Contract Description 19

6 IMPLEMENTATION AND RESULTS 20

7 CONCLUSION AND FUTURE SCOPE 27

APPENDIX-1 REFERENCES 28

vi
LIST OF FIGURES

FIGURE NAME OF THE FIGURES PAGE


NO NO
3.1 Decision tree pseudo-code 6
3.2 Example of nearest neighbors 7
3.3 Example for vector difference 8
4.1 Model methodology 11
4.2 Fake News Detection model 13
5.1 Anoconda Navigator 17
5.2 Installation of Anaconda Packages 18
6.1 Balanced Dataset 20
6.2 News categories 21
6.3 Word cloud for Real news 22
6.4 Word cloud for Real news 22
6.5 Average Word length 23
6.6 Unigram Analysis 23
6.7 Bigram Analysis 24
6.8 Trigram Analysis 24
6.9 Model summary 25
6.10 Analyzing Trained model 26
6.11 Analyzing predicted and actual values 26

vii
LIST OF TABLES

TABLE NAME OF THE TABLES PAGE


NO NO
1 Software Specifications 14
2 Hardware Specification 16

viii
LIST OF ABBREVATIONS

S. NO ABBREVATION EXPANSION

1 NLP Natural Language


processing
2 NER Named Entity Recognition

3 SVM Support Vector Machine

4 NLT Natural Language Toolkit

ix
CHAPTER 1

INTRODUCTION

Polls tell us what proportion of a population has a specific viewpoint. They do not
explain why respondents believe as they do or how to change their minds. This is the
work of social scientists and scholars. Polls are simply a measurement tool that tell us
how a population thinks and feels about any given topic. This can be useful in helping
different cultures understand one another because it gives the people a chance to speak
for themselves instead of letting only vocal media stars speak on behalf of all. This is
where the concept of Opinion polls come in. Opinion polling gives people who do not
usually have access to express their feelings on why they choose what they choose. A
nonbiased opinion poll is a type of survey or inquiry designed to measure the public’s
views regrading a particular topic or series of topics. Trained interviewers ask questions
of people chosen at random from the population being measured. Responses are given,
and interpretations are made based on the results. It is important in a random sample that
everyone in the population being studied has an equal chance of participating.

The existing polling systems or voting systems are vulnerable to various security attacks
like vote alteration and manipulation, malware attacks, DDoS attacks, etc.
With high security and transparency provisions, Blockchain is being widely used in
supply chain management systems, healthcare, payments, business, IOT, voting systems,
etc. Using blockchain, voting can be made more secure, transparent, immutable, and
reliable. Blockchain stores every transaction, so they users can track back their votes. In
blockchain, you can just insert data but cannot update or delete. Hence when you insert
something it stays on immutable forever, I.e., nobody can change it. Blockchain systems
also offer decentralization. If one server goes down or something happens on a particular
node, other nodes can function normally can do not have to wait for victim node’s
recovery.
1
2
SCOPE OF THE PROJECT

The main scope of this project is to develop a cloud-based decentralized polling


application with the help of blockchain technology.

OBJECTIVE OF THE PROJECT

Polling systems should work towards opinion gathering rather than measuring
the majority in a population. Blockchain based voting systems provides many
advances in the voting process such as, transparent polling process, efficient vote
counting, immutable votes, protection from data leaks and many more. In our
project, we let the users express their opinion along with their votes. And with the
help of blockchain technology, we aim towards a completely secure and
decentralized polling system, which works in the most transparent manner.

REPORT SUMMARY

The project report is organized as follows: the chapter 2 narrates the related
work done in this Decentralized polling system, chapter 3 explains the fundamentals and
methodologies, chapter 4 depicts the architecture and design of the proposed
methodology, chapter 5 discuss the system implementation , software and hardware
requirements, chapter 6describes the implementation of blockchain ledger and
creating user interface for Decentralized polling system, the chapter 7 details the
conclusion and future work of the Decentralized and the last section provides the
references and appendix.

3
CHAPTER 2

RELATED ARTICLES

INTRODUCTION

The various research works on the electronic polling using Blockchain.

An efficient and effective Decentralized Anonymous Voting System

A trusted electronic election system requires that all the involved information must
go public, that is, it focuses not only on transparency but also privacy issues. In other
words, each ballot should be counted anonymously, correctly, and efficiently.
Researchers from National Taiwan University proposed a lightweight E-voting
system for voters to minimize their trust in the authority or government. They ensure
the transparency of election by putting all message on the blockchain, in the
meantime, the privacy of individual voter is protected via an efficient and effective
ring signature mechanism. Besides, the attractive self-tallying feature is also built in
our system, which guarantees that everyone who can access the blockchain network
is able to tally the result on his own, no third party is required after voting phase.
More importantly, they ensure the correctness of voting results and keep the gas cost
of individual participant as low as possible, at the same time. Clearly, the pre-
described characteristics make our system more suitable for large-scale election.

Platform-Independent Secure Blockchain-Based Voting System

Cryptographic techniques are employed to ensure the security of voting


systems in order to increase its wide adoption. However, in such electronic voting
systems, the public bulletin board that is hosted by the third party for publishing and
auditing the voting results should be trusted by all participants. Recently a number
4
of blockchain-based solutions have been proposed to address this issue. However,
these systems are impractical to use due to the limitations on the voter and candidate
numbers supported, and their security framework, which highly depends on the
underlying blockchain protocol and suffers from potential attacks (e.g., force-
abstention attacks). To deal with two aforementioned issues, a practical platform-
independent secure and verifiable voting system that can be deployed on any
blockchain that supports an execution of a smart contract.

5
CHAPTER 3

RELATED WORK

Electronic Voting

Electronic voting, a form of computer-mediated voting in which voters make


their selections with the aid of a computer. To understand electronic voting, it is
convenient to consider four basic steps in an election process: ballot composition, in
which voters make choices; ballot casting, in which voters submit their ballots; ballot
recording, in which a system records the submitted ballots; and tabulation, in which
votes are counted. Ballot casting, recording, and tabulation are routinely done with
computers even in voting systems that are not, strictly speaking, electronic. Electronic
voting in the strict sense is a system where the first step, ballot composition (or
choosing), is done with the aid of a computer. And now we’re going to use blockchain
to implement E-voting which manages ballot casting, recording and tabulations more
securely and anonymously.

Decentralization
In blockchain, decentralization refers to the transfer of control and decision-making
from a centralized entity (individual, organization, or group thereof) to a distributed
network. Decentralized networks strive to reduce the level of trust that participants must
place in one another, and deter their ability to exert authority or control over one another
in ways that degrade the functionality of the network.
Decentralization is not a new concept. When building a technology solution,
three primary network architectures are typically considered: centralized, distributed,
and decentralized. While blockchain technologies often make use of decentralized
networks, a blockchain application itself cannot be categorized simply as being

6
decentralized or not. Rather, decentralization is a sliding scale and should be applied to
all aspects of a blockchain application. By decentralizing the management of and access
to resources in an application, greater and fairer service can be achieved.
Decentralization typically has some tradeoffs such as lower transaction throughput, but
ideally, the tradeoffs are worth the improved stability and service levels they produce.

Blockchain
A blockchain is essentially a shared, immutable digital ledger of transactions that
is duplicated and distributed across the entire network of computer systems on the
blockchain. Each block in the chain contains a number of transactions, and every time
a new transaction occurs on the blockchain, a record of that transaction is added to
every participant’s ledger. The decentralized database managed by multiple
participants is known as Distributed Ledger Technology (DLT).
Blockchain is a type of DLT in which transactions are recorded with an immutable
cryptographic signature called a hash.

Fig. 3.1 Properties of DLT

7
NEAR Protocol
NEAR is a Layer-1 blockchain solution built for an ecosystem’s underlying base
network and infrastructure. Bitcoin and Ethereum are examples of some other Layer-1
blockchains. These blockchains finalize and validate transactions as well as secure the
network from malicious behavior by incentivizing validators with rewards. In this case,
validators are rewarded with NEAR cryptocurrency tokens.
NEAR is a collective, a foundation, and a development platform built on a new
layer-one blockchain.
NEAR runs in concert with Ethereum, Polkadot, Cosmos, and more, allowing
for the free flow of assets and communication between networks for the betterment of
all.
NEAR is a development platform build on a sharded, proof-of-stake, layer-one
blockchain designed for usability.

Fig. 3.2 Working of NEAR protocol

8
Smart Contract
A "smart contract" is simply a program that runs on the blockchain. It's a
collection of code (its functions) and data (its state) that resides at a specific address on
the Ethereum blockchain.
Smart contracts are a type of account. This means they have a balance and they can
send transactions over the network. However, they're not controlled by a user, instead
they are deployed to the network and run as programmed. User accounts can then
interact with a smart contract by submitting transactions that execute a function defined
on the smart contract. Smart contracts can define rules, like a regular contract, and
automatically enforce them via the code. Smart contracts cannot be deleted by default,
and interactions with them are irreversible.

Blockchain Wallet
A blockchain wallet is a digital wallet that allows users to store and manage their
Bitcoin, Ether, and other cryptocurrencies. A blockchain wallet allows transfers in
cryptocurrencies and the ability to convert them back into a user's local currency.
Transactions are secure, as they are cryptographically signed. The wallet is
accessible from web devices, including mobile ones, and the privacy and identity of the
user are maintained. So, a blockchain wallet provides all the features that are necessary
for safe and secure transfers and exchanges of funds between different parties.

9
10
Meta Transactions
This is a fancy name for a simple idea: a third-party (called a relayer) can send
another user’s transactions and pay themselves for the gas cost. In this scheme, users
sign messages (not transactions) containing information about a transaction they would
like to execute. Relayers are then responsible for signing valid transactions with this
information and sending them to the network, paying for the gas cost. A base contract
preserves the identity of the user that originally requested the transaction. In this way,
users can interact directly with smart contracts without needing to have a wallet or own
currency.
This means that, in order to support meta transactions in your application, you
need to keep a relayed process running - or leverage a decentralized relayer network.

11
CHAPTER 4

PROPOSED

METHODOLOGY

METHODOLOGY

This section presents the methodology used for the creating the decentralized polling
system. A solidity directory is initialized and the avalanche details, avalanche wallet
are collected and store the mnemonics in an “.env” file. Smart contracts are created
using solidity and one Main contract is created for maintaining all sub contacts. The
smart contracts and the main contract created needs to be deployed to the blockchain.
This is done with the help of migrations. We fund the account and run these
migrations. A user interface for polling is built using React framework. We have 3
main components in user interface: One for creating elections, one for viewing the
active elections and one for viewing specific election and casting the vote.

12
Fig. 4.1 Process of Development

13
In our application, Individual users can login and create polls. When the user
creates a poll or votes on a poll, they’ll be asked to sign their transaction, once they
sign the transaction the transaction_Id, user_signature and timestamp is sent to the
smart contract for the specific poll. Each individual poll has its own smart contract and
the smart contract which is written in solidity executes itself and deployed the
transaction into the avalanche network.

In the avalanche network the transaction is broadcasted to different nodes present in the
network and upon receiving the details of the transaction each node performs an
operation to verify the transaction with the transaction_Id and
user_signature. Verified transactions are then added to the chain. After the vote is
added to the chain, the total transactions are processed and the results are immediately
sent to the front-end. The vote count is displayed simultaneously to all users and the
final results are displayed after the time of the poll runs out.

Fig. 4.2 Application flow


14
CHAPTER 5

SYSTEM SPECIFICATION

Software Requirement

Table I. Software Specifications


S. No Software Versi URL
on
1 Nodejs 10.16 https://nodejs.org/en/
2 NPM 5.6 https://www.npmjs.com/
3 ReactJs 18.1.0 https://reactjs.org/
4 Solidity 0.8.14 https://docs.soliditylang.org/en/v0.8.14/
5 Truffle Suite https://trufflesuite.com/
6 Metamask https://metamask.io/

NodeJS

Node.js is an open-source and cross-platform JavaScript runtime


environment. It is a popular tool for almost any kind of project! It runs the V8
JavaScript engine, the core of Google Chrome, outside of the browser. This allows
Node.js to be very performant.
A Node.js app runs in a single process, without creating a new thread for
every request. Node.js provides a set of asynchronous I/O primitives in its standard
library that prevent JavaScript code from blocking and generally, libraries in
Node.js are written using non-blocking paradigms, making blocking behavior the
exception rather than the norm.

15
NPM

NPM (Node Package Manager) is a package manager for the JavaScript


programming language maintained by npm, Inc. npm is the default package
manager for the JavaScript runtime environment Node.js. It consists of a command
line client, also called npm, and an online database of public and paid-for private
packages, called the npm registry. The registry is accessed via the client, and the
available packages can be browsed and searched via the npm website. The package
manager and the registry are managed by npm, Inc.

16
ReactJs

ReactJS tutorial provides basic and advanced concepts of ReactJS. Currently, ReactJS
is one of the most popular JavaScript front-end libraries which has a strong foundation
and a large community.
ReactJS is a declarative, efficient, and flexible JavaScript library for building
reusable UI components. It is an open-source, component-based front-end library
which is responsible only for the view layer of the application. It was initially
developed and maintained by Facebook and later used in its products like WhatsApp
& Instagram.

Solidity

Solidity is an object-oriented, high-level language for implementing smart


contracts. Smart contracts are programs which govern the behavior of accounts
within the Ethereum state.
Solidity is a curly-bracket language designed to target the Ethereum Virtual
Machine (EVM). It is influenced by C++, Python and JavaScript. You can find more
details about which languages Solidity has been inspired by in the language
influences section.

Truffle Suite

Truffle is a development environment, testing framework and asset pipeline


for Ethereum, aiming to make life a developer easier.
The Truffle Suite is a collection of tools made specifically for blockchain
development on Ethereum. The suite includes three pieces of software:
• Truffle, a framework for smart contract development
17
• Ganache, which enables you to set a personal Ethereum blockchain on the local
network for testing and development
• Drizzle, which is used for creating DApp user interfaces and includes a collection
of ready-to-use components

Metamask

MetaMask is a software cryptocurrency wallet used to interact with the


blockchain. It allows users to access their Ethereum wallet through a browser extension
or mobile app, which can then be used to interact with decentralized applications.
MetaMask is developed by ConsenSys Software Inc., a blockchain software company
focusing on Ethereum-based tools and infrastructure.

18
Hardware Requirement

Table II. Hardware Specification

Processor IntelCore
Operating System Windows 10 (64-bit)
RAM 4 GB

Installation procedure

Step 1 — Install the dependencies for Windows


1. Download & install N o d e j s v10.16 from nodejs.org a n d
NPM v5.6 from npmjs.com to get a JavaScript engine for the
development and package manager to manage project dependencies
respectively.

19
2. Install ReactJs using the following command:

“npm install react react-dom”.

ReactJs is the most popular front-end development framework . TensorFlow is the most
popular AI software library and is created/maintained by Google. Keras is another
highly popular & high-level neural networks API, written in Python and capable of
running on top of TensorFlow. It was developed with a focus on enabling fast
experimentation.and is created/maintained by Facebook. It is a component-based
framework where all the UI parts are built as components. It was developed with a
focus on enabling fast experimentation.

3. Install truffle suite using the following command:

“npm install truffle –g”

Truffle suite is collection for software like ganache, truffle, and drizzle. It is used to
create a local Ethereum virtual machine (EVM), where we can deploy our smart
contract for testing. It is a development environment, testing framework and asset
pipeline for Ethereum, aiming to make life a developer easier.

4. Create an account in Avalanche wallet. After creating you’ll be taken to a


dashboard where you can see you balance and wallet address.

20
5. In the dashboard we can see the wallet address, copy the address and add
some fund by pasting your address in faucet.avax.network.

21
22
Smart Description

• Poll is a Solidity contract that lets us view the name and description, the
candidates standing in a poll, and vote for them. For this dApp, we will be
accessing the deployed poll contracts using their address and ABI. This Solidity
code is what will be deployed to the blockchain, each time we create a new
election.
• MainContract is the entry point of our dApp. To create a new poll, we need to
call the createpoll() function from this deployed contract. It will maintain the total
number of election contracts deployed, their address on the network and will also
help in deploying them.

23
CHAPTER 6

IMPLEMENTATION AND RESULTS

The system of polling using blockchain is achieved using several phases. We


generate ReactJs code using create-react-app, which will help us modify our
frontend. For the backend, Solidity smart contracts will be deployed to the
Avalanche blockchain using Truffle suite.

First, we Initialize the working directory. Smart contracts will be made using solidity
Language and will be deployed to avalanche using truffle suite. So, we setup the
working directory according to React and Truffle. We use the web3
, which is an instance of metamask , in our App component for interacting with the
Avalanche network. Next, we need to setup our truffle project.

24
Fig. 6.1. Working directory
Solidity code will be stored in the contracts directory. Deployment functions will be
stored in the migrations folder. The truffle-config-default.js file helps us to connect
to the Avalanche network and we will require an Avalanche node’s RPC URL along
with an Avalanche wallet mnemonic for deploying the contract on the network. An
avalanche wallet is required to keep our funds, required for all the transactions on
the network. The mnemonic of the avalanche wallet is now stored in an “.env” file.

25
Fig. 6.2. Execution of React App

The app is now running successfully. We have to create an election smart contract. A
Poll.sol file is created inside of the contracts directory. This Poll smart contract is used
to view the options of the Poll, name and description of the poll, and it let us vote for
them. This solidity code will be deployed to blockchain every time we create a new
poll. We need another smart contract to maintain all the individual poll contracts
created. For this we create the MainContract.sol file inside of our contracts directory.
This will maintain the total number of poll contracts deployed, their address on the
network and will also help in deploying them. We also need to import the Poll.sol into
this file.

The smart contracts we created needs to deployed to the blockchain. We can use the
migrations directory for this. Create a file named “deploy_contracts.js” to deploy the
MainContract and Poll smart contract to blockchain. Every time we make changes to
our solidity source files or made new solidity files; we have to run “truffle compile”

26
inside the root project directory. Expected output will look like this:
Compiling your contracts...
===========================
> Compiling ./contracts/Poll.sol
> Compiling ./contracts/MainContract.sol
> Compiling ./contracts/Migrations.sol

> Artifacts written to /clg/mini pro/code/dpoll/build/contracts


> Compiled successfully using:
- solc: 0.8.0+commit.c7dfd78e.Emscripten.clang

We need funds to deploy our smart contracts to C-Chain. Inside the truffle-config.js,
HDWalletProvider will help us in deploying on Fuji C-Chain and deployment cost will
be managed by the account whose mnemonic has been stored in “the .env” file.
So, the account needs to be funded.

27
Fig. 6.3. truffle-config.js file

After funding the account, we are finally set to run migrations and deploy the
MainContract. Use the command “truffle migrate –network fuji”, followed by “truffle
migrate –network development”.
After this successful execution the migrations are created and deployed to the C-Chain.

28
Fig. 6.4 Running Migrations

29
The final step is the creation of User Interface. We require a component to connect
our browser to the avalanche network. This component is called BlockchainUtils
Component.

Fig. 6.5 BlockchainUtils Component

30
Next we need 3 main components for user interaction.
(i) CreatePoll component: This component is used to create a new poll by an user.
(ii) ActivePolls component: This component Displays the set of active polls to all
users.
(iii) VoteModal Component: This component displays the Poll information
and options available to vote. The users can cast in their vote and also provide
their opinions on the matter.

31
Fig.6.7 CreatePolls component

32
33
34
35
36
Fig. 6.8 ActivePolls Component

37
Fig. 6.9 Model summary

38
39
CHAPTER7

CONCLUSION AND FUTURE SCOPE

In this project, how Blockchain can be useful for Electronic Voting and how it
can be used for examining the confidentiality is explored. Despite the advancement
in blockchain using various techniques and networks, they still face some issues in
terms of cost and time efficiency. The proposed framework uses Avalanche network
so the gas fees and the time taken per entry is so much better than other blockchain
networks like Ethereum. In the future we can implement meta transactions to avoid
payment of gas fees on voter’s end instead we can create our own token pay with it.
Thereby this model is more secure and efficient than other electric and non-electric voting
methods.

40
APPENDIX – I

CODING

NEAR CONGIFURATION

const CONTRACT_NAME = process.env.CONTRACT_NAME ||'blockvote'


function getConfig(env) {
switch (env) {
case 'production':
case 'mainnet':
return {
networkId: 'mainnet',
nodeUrl: 'https://rpc.mainnet.near.org',
contractName: CONTRACT_NAME,
walletUrl: 'https://wallet.near.org',
helperUrl: 'https://helper.mainnet.near.org',
explorerUrl: 'https://explorer.mainnet.near.org',
}
case 'development':
case 'testnet':
return {
networkId: 'testnet',
nodeUrl: 'https://rpc.testnet.near.org',
contractName: CONTRACT_NAME,
walletUrl: 'https://wallet.testnet.near.org',

41
helperUrl: 'https://helper.testnet.near.org',
explorerUrl: 'https://explorer.testnet.near.org',
}
case 'betanet':
return {
networkId: 'betanet',
nodeUrl: 'https://rpc.betanet.near.org',
contractName: CONTRACT_NAME,
walletUrl: 'https://wallet.betanet.near.org',
helperUrl: 'https://helper.betanet.near.org',
explorerUrl: 'https://explorer.betanet.near.org',
}
case 'local':
return {
networkId: 'local',
nodeUrl: 'http://localhost:3030',
keyPath: `${process.env.HOME}/.near/validator_key.json`,
walletUrl: 'http://localhost:4000/wallet',
contractName: CONTRACT_NAME,
}
case 'test':
case 'ci':
return {
networkId: 'shared-test',

42
nodeUrl: 'https://rpc.ci-testnet.near.org',
contractName: CONTRACT_NAME,
masterAccount: 'test.near',
}
case 'ci-betanet':
return {
networkId: 'shared-test-staging',
nodeUrl: 'https://rpc.ci-betanet.near.org',
contractName: CONTRACT_NAME,
masterAccount: 'test.near',
}

default:
throw Error(`Unconfigured environment '${env}'. Can be configured in
src/config.js.`)
}
}
module.exports = getConfig

Connect Wallet

<script>
const currentUrl = new URL(window.location.href);
const message = `NODE_ENV=local near create_account {newAccountId} --
masterAccount {masterAccountId} --publicKey
${currentUrl.searchParams.get('public_key')} --initialAmount
43
10000000000000000000`;
document.getElementById('shell-command').innerText = message;

function done() {
const successUrl = new URL(currentUrl.searchParams.get('success_url'));
successUrl.searchParams.set('account_id',

document.getElementById('accountId').value);
successUrl.searchParams.set('public_key',
currentUrl.searchParams.get('public_key'));
window.location.assign(successUrl.toString());
}
</script>
Utility functions

import { connect, Contract, keyStores, WalletConnection } from "near-api-js";


import getConfig from "./config";

const nearConfig = getConfig(process.env.NODE_ENV || "development");

// Initialize contract & set global variables


export async function initContract() {
// Initialize connection to the NEAR testnet
const near = await connect(
Object.assign(
{ deps: { keyStore: new keyStores.BrowserLocalStorageKeyStore() } },
nearConfig
)
);

// Initializing Wallet based Account. It can work with NEAR testnet wallet that
44
// is hosted at https://wallet.testnet.near.org
window.walletConnection = new WalletConnection(near);

// Getting the Account ID. If still unauthorized, it's just empty string
window.accountId = window.walletConnection.getAccountId();

// Initializing our contract APIs by contract name and configuration


window.contract = await new Contract(
window.walletConnection.account(),
nearConfig.contractName,
{
// View methods are read only. They don't modify the state, but usually return some
value.

viewMethods: [
"getGreeting",
"didParticipate",
"getAllPrompts",
"getVotes",
"getUrl",
"getCandidatePair",
,
],
// Change methods can modify the state. But you don't receive the returned value
when called.
changeMethods: [
"addUrl",
"addCandidatePair",
"addToPromptArray",
"addVote",
"recordUser",
"clearPromptArray",
],
}
);
}

export function logout() {


window.walletConnection.signOut();
45
// reload page
window.location.replace(window.location.origin + window.location.pathname);
}

export function login() {


// Allow the current app to make calls to the specified contract on the
// user's behalf.
// This works by creating a new access key for the user's account and storing
// the private key in localStorage.
window.walletConnection.requestSignIn(nearConfig.contractName);
}

46
APPENDIX – II

REFERENCES

[1] The Blockchain as a Decentralized Security Framework By Deepak Puthal,


Nisha Malik, Saraju P. Mohanty, Elias Kougianos, and Chi Yang.
[2] S. Nakamoto. Bitcoin: A peer-to-peer electronic cash system. [Online].
Available: https:// bitcoin.org/bitcoin.pdf

[3] P. Bailis, A. Narayanan, A. Miller, and S. Han, “Research for practice:


Cryptocurrencies, blockchains, and smart contracts; hardware for deep
learning,” Commun. ACM, vol. 60, no. 5, pp. 48–51, 2017
[4] D. Puthal, S. P. Mohanty, P. Nanda, and U. Choppali, “Building security
perimeters to protect network systems against cyber threats,” IEEE Consum.
Electron. Mag., vol. 6, no. 4, pp. 24–27, 2017
[5] Kanika Garg, Pavi Saraswat, Sachin Bisht, Sahil Kr. Aggarwal, Sai Krishna
Kothuri, Sahil Gupta “A Comparitive Analysis on E-Voting System Using
Blockchain” 978-1-7281-1253-4/19 2019 IEEE
[6] M. Hellman, Yavuz, Emre, Ali Kaan Koç, Umut Can Çabuk, and Gökhan
Dalkılıç. "Towards secure e-voting using ethereum blockchain." In 2018 6th
International Symposium on Digital Forensic and Security (ISDFS), pp. 1-7.
IEEE, 2018
[7] Faour, Nazim. "Transparent Voting Platform Based on Permissioned
Blockchain." arXiv preprint arXiv:1802.10134(2018)

47
[8] Meter, Christian. "Design of distributed voting systems." arXiv preprint
arXiv:1702.02566 (2017).
[9] Dagher, Gaby G., Praneeth Babu Marella, Matea Milojkovic, and Jordan
Mohler. "BroncoVote: Secure Voting System Using Ethereum’s Blockchain."
(2018).
[10] Hardwick, Freya Sheer, Raja Naeem Akram, and Konstantinos
Markantonakis. "E-Voting with Blockchain: An E-Voting Protocol with
Decentralisation and Voter Privacy." arXiv preprint arXiv:1805.10258
(2018).
[11] Platform-Independent Secure Blockchain-Based Voting System by
Bin Yu, Joseph K. Liu , Amin Sakzad, Surya Nepal, Ron Steinfeld, Paul
Rimba, and Man Ho Au
[12] Adida, B.: Helios: web-based open-audit voting. In: USENIX Security
Symposium, vol. 17, pp. 335–348 (2008)
[13] Au, M.H., Chow, S.S.M., Susilo, W., Tsang, P.P.: Short linkable ring
signatures revisited. In: Atzeni, A.S., Lioy, A. (eds.) EuroPKI 2006. LNCS,
vol. 4043, pp. 101–115. Springer, Heidelberg (2006).
https://doi.org/10.1007/11774716 9
[14] Au, M.H., Liu, J.K., Susilo, W., Yuen, T.H.: Certificate based
(linkable) ring signature. In: Dawson, E., Wong, D.S. (eds.) ISPEC 2007.
LNCS, vol. 4464, pp. 79–92. Springer, Heidelberg (2007).
https://doi.org/10.1007/978-3-540-72163-5 8
[15] Yu, B., et al.: Platform-independent secure blockchain-based voting
system. Cryptology ePrint Archive, change me (2018).
http://eprint.iacr.org/2018/

48

You might also like