# Invalid opcode: opcode 0xfe not defined

**URL:** <https://forum.openzeppelin.com/t/invalid-opcode-opcode-0xfe-not-defined/14132>\
**Category:** Smart Contracts\
**Created:** [August 18, 2021, 6:20am UTC](https://forum.openzeppelin.com/t/invalid-opcode-opcode-0xfe-not-defined/14132 "2021-08-18T06:20:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lloyd\_Ramos](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/lloyd_ramos/32/4832_2.png) [@Lloyd\_Ramos](https://forum.openzeppelin.com/u/Lloyd_Ramos)\
**Post date:** [August 18, 2021, 6:20am UTC](https://forum.openzeppelin.com/t/invalid-opcode-opcode-0xfe-not-defined/14132/1 "2021-08-18T06:20:32Z")

</div>

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](https://github.com/laronlineworld/bettingOrig/blob/main/BettingOrgi.sol)

Anyone could help figuring out the distribution of prizes?

```auto
/* 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;
}

```
