-
Notifications
You must be signed in to change notification settings - Fork 0
/
voteFor.js
28 lines (24 loc) · 826 Bytes
/
voteFor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
if(!process.argv[4])
console.log("You have to enter an account!");
if(!process.argv[5])
console.log("You have to enter a candidate value!");
var Election = artifacts.require("TurkishElections");
let account = process.argv[4];
let regulator_key = "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=";
module.exports = function(done) {
if(process.argv[4] && process.argv[5]){
Election.deployed().then(function(instance) {
return instance.vote(process.argv[4], process.argv[5], {privateFor: [regulator_key]});
}).then(function(result){
console.log("Transaction:", result.tx);
console.log("Block Number:", result.receipt.blockNumber);
console.log("Account " + process.argv[4] + " voted for " + process.argv[5] + "!");
done();
}).catch(function(e) {
console.log(e);
done();
});
}
else
done();
};