-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Hi,
I was using Election.sol and could not compile it. With the solidity version ^0.5.8, the following changes are required.
SUMMARY:
- update solidity version.
- error message for require().
- public before other modifiers.
- valid argument in selfdestruct().
DETAILS:
-
pragma solidity ^0.4.21;
to be changed to
pragma solidity ^0.5.8; -
require(msg.sender == owner);
to be changed to
require(msg.sender == owner, "Sender NOT authorized."); -
constructor(string _name) public {...}
to be changed to
constructor(string memory _name) public {...} -
function addCandidate(string name) ownerOnly public {...}
to be changed to
function addCandidate(string memory name) public ownerOnly {...} -
function authorize(address person) ownerOnly public {...}
to be changed to
function authorize(address person) public ownerOnly {...} -
require(!voters[msg.sender].voted);
to be changed to
require(!voters[msg.sender].voted, "Voter has already voted"); -
require(voters[msg.sender].authorized);
to be changed to
require(voters[msg.sender].authorized, "Voter not authorized"); -
function end() ownerOnly public {...}
to be changed to
function end() public ownerOnly {...} -
selfdestruct(owner);
to be changed to
selfdestruct(msg.sender);
I am not sure if this workshop contracts requires updating but searching Election.sol by Blockgeeks gives this as a top search result. And I think new people can benefit from this.