작성
·
576
1
버전은 0.5.1입니다.
영상과 똑같이 작성했고 뭐가 문제인지 잘 모르겠어서 질문 드립니다~
function addCandidator ~ public owner {
function upVote~ public {
function finishvote~public onlyowner{이 세부분이 에러났습니다.
brower/vote.sol : 40:5 DeclarationError: Identifier already declared.
function addCandidator(string _name) public onlyowner {
^(relevant source part starts here and spans across multiple lines).
brower/vote.sol : 20:5: the previous declaration is here:
event addCandidator(string name);
^---------------------------------------------^
이라고 써져 있고요. 볼드 처리한 곧은 전부 동일한 에러입니다.
pragma solidity 0.5.1; //버전 명시
contract vote {
//structure
struct candidator {
string name;
uint upVote;
}
//variable
bool live;
address owner;
candidator[] public candidatorlist;
//napping
mapping(address => bool) voted;
//event
event addCandidator(string name);
event upVote(string candidator, uint upVote);
event finishvote(bool live);
event voting(address owner);
//modifier
modifier onlyowner {
require(msg.sender == owner);
_;
}
//constructor
constructor() public {
owner = msg.sender;
live = true;
emit voting(owner);
}
//candidator
function addCandidator(string _name) public onlyowner {
require(live == true);
require(candidatorlist.length < 5);
candidatorlist.push(candidator(_name, 0));
//emit event
emit addCandidator (_name);
}
//voting
function upVote(uint _indexOfcandidator) public {
require(_indexOfcandidator < candidatorlist.length);
require(voted[msg.sender] == false);
candidatorlist[_indexOfcandidator].upVote++;
voted[msg.sender] = true;
emit upVote(candidatorlist[_indexOfcandidator].name, candidatorlist[_indexOfcandidator].upVote);
}
//finish vote
function finishvote() public onlyowner{
live = false;
emit finishvote(live);
}
}
}