0
When distributing prize, this error will show:{ "code": -32000, "message": "invalid opcode: opcode 0xfe not defined" }
full code here:https://github.com/laronlineworld/bettingOrig/blob/main/BettingOrgi.sol
Anyone could help figuring out the distribution of prizes?
/* Function to close voting and handle payout. Can only be called by the owner. */
function closeVoting() onlyOwner public returns (bool) {
require(bettingActive);
bytes32 winningCandidate = candidateList[getWinner()];
// getting list of winners and losers
// and the money lost by all losers
address[] memory winners;
uint256 numWinners = 0;
uint256 numLosers = 0;
uint256 surplus = 0;
for (uint x = 0; x < betters.length; x++) {
if (bets[winningCandidate][betters[x]] > 0) {
winners[numWinners++] = betters[x];
} else {
surplus += bets[winningCandidate][betters[x]];
numLosers++;
}
}
// keeping 10% as service fee and distribute rest among the winners
uint256 prize = surplus * 9 / 10;
// calculate prize per winner
prize = prize / numLosers;
// distribute the prize to the winners alongwith the money they bet in
for (x = 0; x < winners.length; x++) {
winners[x].transfer(prize + bets[winningCandidate][winners[x]]);
}
// Close the betting period
bettingActive = false;
return true;
}