forked from ethereum/remix-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremix-test.json
12 lines (12 loc) · 2.18 KB
/
remix-test.json
1
2
3
4
5
6
7
8
9
10
11
12
{
"action": "verifysourcecode",
"apikey": "CC4YVQGTC45H2IXX6BDUNP54TXJHKVMWY5",
"compilerversion": "v0.5.1+commit.c8a2cb62",
"constructorArguements": "",
"contractaddress": "0x43e9d8ad985fb8428d93f4180705a6d06030fee9",
"contractname": "Ballot",
"module": "contract",
"optimizationUsed": "0",
"runs": "200",
"sourceCode": "pragma solidity >=0.4.22 <0.6.0;\ncontract Ballot {\n\n struct Voter {\n uint weight;\n bool voted;\n uint8 vote;\n address delegate;\n }\n struct Proposal {\n uint voteCount;\n }\n\n address chairperson;\n mapping(address => Voter) voters;\n Proposal[] proposals;\n\n /// Create a new ballot with $(_numProposals) different proposals.\n constructor(uint8 _numProposals) public {\n chairperson = msg.sender;\n voters[chairperson].weight = 1;\n proposals.length = _numProposals;\n }\n\n /// Give $(toVoter) the right to vote on this ballot.\n /// May only be called by $(chairperson).\n function giveRightToVote(address toVoter) public {\n if (msg.sender != chairperson || voters[toVoter].voted) return;\n voters[toVoter].weight = 1;\n }\n\n /// Delegate your vote to the voter $(to).\n function delegate(address to) public {\n Voter storage sender = voters[msg.sender]; // assigns reference\n if (sender.voted) return;\n while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)\n to = voters[to].delegate;\n if (to == msg.sender) return;\n sender.voted = true;\n sender.delegate = to;\n Voter storage delegateTo = voters[to];\n if (delegateTo.voted)\n proposals[delegateTo.vote].voteCount += sender.weight;\n else\n delegateTo.weight += sender.weight;\n }\n\n /// Give a single vote to proposal $(toProposal).\n function vote(uint8 toProposal) public {\n Voter storage sender = voters[msg.sender];\n if (sender.voted || toProposal >= proposals.length) return;\n sender.voted = true;\n sender.vote = toProposal;\n proposals[toProposal].voteCount += sender.weight;\n }\n\n function winningProposal() public view returns (uint8 _winningProposal) {\n uint256 winningVoteCount = 0;\n for (uint8 prop = 0; prop < proposals.length; prop++)\n if (proposals[prop].voteCount > winningVoteCount) {\n winningVoteCount = proposals[prop].voteCount;\n _winningProposal = prop;\n }\n }\n}"
}