Hi all, can anyone help me with some hints? I am studying solidity development, found out in solidity official guide the contract for the voting system. Trying to implement a way to allow multiple user in one call to vote, but unfortunately I have some trouble with the arrays. I want to return the list of not accepted address (such as, already present). This is the code, can anyone help me how should I fix the notVoting address array? When it's executed the notvoting[0] = address(0) it goes in overflow.

function giveRightToVoteToMultiple(address[] memory voters_) public returns (address[] memory notVoting) {
require(msg.sender == principal,"IT'S NOT YOU WHO DECIDE");
uint notVotingAccount;
notVoting[0] = address(0);
for(uint i = 0; i < voters_.length; i++){
if(voters[voters_[i]].weight != 0 || voters[voters_[i]].voted){
notVoting[notVotingAccount] = voters_[i];
notVotingAccount ++;
} else {
voters[voters_[i]].weight = 1;
}
}
return notVoting;
}

Aug 27, 2021, 12:50 PM
Sorry guys, noone?
Aug 27, 2021, 1:13 PM

© 2024 Draquery.com All rights reserved.