Skip to content

Instantly share code, notes, and snippets.

@maheshmurthy
Created April 12, 2018 18:14
Show Gist options
  • Save maheshmurthy/756dbbaa7b577501c310cfe8e5e1ee40 to your computer and use it in GitHub Desktop.
Save maheshmurthy/756dbbaa7b577501c310cfe8e5e1ee40 to your computer and use it in GitHub Desktop.
window.submitVote = function(candidate) {
let candidateName = $("#candidate-name").val();
let signature = $("#vote-signature").val();
let voterAddress = $("#voter-address").val();
$("#msg").html("Vote has been submitted. The vote count will increment as soon as the vote is recorded on the blockchain. Please wait.")
Voting.deployed().then(function(contractInstance) {
contractInstance.voteForCandidate(candidateName, voterAddress, signature, {gas: 140000, from: web3.eth.accounts[0]}).then(function() {
let div_id = candidates[candidateName];
console.log(div_id);
return contractInstance.totalVotesFor.call(candidateName).then(function(v) {
console.log(v.toString());
$("#" + div_id).html(v.toString());
$("#msg").html("");
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment