Академический Документы
Профессиональный Документы
Культура Документы
E-voting System
Submitted by:
Group 12
Solidity Code
Here we take candidate name and add the candidate and then we check if candidate exists and
if their votes are already received or not and if not received the vote count has been increased
to 1
contract CastYourVote
{
string[] candidateList;
mapping(string=>uint8) VotesReceived; // 'A' => 3 Votes, 'B' =>5 votes VotesReceived[A] = 3,
VotesReceived[B]=5
candidateList.push(candidateName);
log('candidate List ', candidateList[0]);
HTML Code
<!DOCTYPE html>
<html>
<head>
<title>Voting DApp</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet'
type='text/css'>
<link href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'
rel='stylesheet' type='text/css'>
</head>
<body class="container">
<h1>A Simple Voting Application</h1>
<div id="address"></div>
<div class="table-responsive">
<table class="table table-bordered" id="myTable">
<thead>
<tr>
<th>Candidate</th>
<th>Votes</th>
</tr>
</thead>
<tbody>
<tr>
<td>User1</td>
<td id="candidate-0"></td>
</tr>
</tbody>
</table>
<div id="msg"></div>
</div>
<input type="text" id="candidate" />
<a href="#" onclick="voteForCandidate()" class="btn btn-primary">Vote</a>
<input type="text" id="newCandidate" />
<a href="#" onclick="addCandidate()" class="btn btn-primary">Add Candidate</a>
</body>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="app.js"></script>
</html>
App.js code
/ Import the page's CSS. Webpack will know what to do with it.
import "../stylesheets/app.css";
// Import our contract artifacts and turn them into usable abstractions.
import voting_artifacts from '../../build/contracts/CastYourVote.json'
}
}
});
}
window.addCandidate = function(candidate) {
window.onload = function() {
});
Output
Advantages of using the Block chain
Anonymity of the voters will be protecting suing this system. Tampering, recasting of
votes will not be possible with this secure system
Counting of votes will be made much easier, faster and with the least amount of
manual intervention possible
Apart from the initial costs of set-up, the voting process will be a fairly reasonable
process.
Ambiguities can be avoided and casting of votes will be made much easier
Transparency and clarity can be given to the voters since the block being added will be
ratified
The votes can be made publically available with the identity of the voters being
cryptographically hidden, with no means of access
With a distributed ledger there is no single point of failure and accountability in the
system
Public confidence, security and trust in the block chain system is difficult to build. it is
still a relatively new concept being experimented upon and hence not very openly
spoken and ratified
There has not been sufficient use of the system to vouch for the right application of it
With the amount of energy used to mine a block, national e-voting using block chain
might not be a good option for India