• 카테고리

    질문 & 답변
  • 세부 분야

    블록체인

  • 해결 여부

    미해결

에러가 뜨는데..

18.12.11 22:44 작성 조회수 424

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);
}

}
}

답변 2

·

답변을 작성해보세요.

0

이성복님의 프로필

이성복

2021.05.11

event로 지정한 addCandidator와 function의 이름인 addCandidator가 동일해서 일어난 문제인 것 같아요

0

냠냠이님의 프로필

냠냠이

2021.02.19

저도 업보트 에러가 뜨네요 ㅠㅠ

transact to Vote.upVote errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.0.8)