diff --git a/src/contracts/Election.sol b/src/contracts/Election.sol index f64574c..ed5ce74 100644 --- a/src/contracts/Election.sol +++ b/src/contracts/Election.sol @@ -81,4 +81,25 @@ contract VotingForPurpose{ voterslist.push(_voteraddress); totalregisteredvoters++; } + + function authorize( + address _voter) public ownerOn{ + voters[_voter].authorized= true; + } + + function startVoting(uint _electionid) public ownerOn{ + require(elections[_electionid].status==1 && elections[_electionid].candidatesids.length>=2); + elections[_electionid].status=2; + } + + function endElection(uint _electionid) public ownerOn{ + require(elections[_electionid].status==2); + elections[_electionid].status=3; + } + + function vote(address _address,uint _candidateID,uint _electionid) public checkvote(_address,_candidateID,_electionid){ + voted[_address][_electionid]=true; + candidates[_candidateID].voteCount++; + elections[_electionid].totalVotes++; + } } \ No newline at end of file diff --git a/src/utils/election.json b/src/utils/election.json index a889f87..571cbf4 100644 --- a/src/utils/election.json +++ b/src/utils/election.json @@ -49,6 +49,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "_voter", + "type": "address" + } + ], + "name": "authorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -161,6 +174,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_electionid", + "type": "uint256" + } + ], + "name": "endElection", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -180,6 +206,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_electionid", + "type": "uint256" + } + ], + "name": "startVoting", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "totalregisteredvoters", @@ -193,6 +232,29 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_candidateID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_electionid", + "type": "uint256" + } + ], + "name": "vote", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ {