Skip to main content
1 of 2
Gopal ojha
  • 2.2k
  • 2
  • 12
  • 21

To fulfill your requirement may be returns may solve it.

  function revealWinners() public returns (uint) {
        for (uint id = 0; id <3; id++) {
            Item storage currentItem=items[id];
            if(currentItem.itemTokens.length != 0) {
                uint randomIndex = (block.number /
                currentItem.itemTokens.length)% currentItem.itemTokens.length;
                uint winnerId = currentItem.itemTokens[randomIndex];
                return winnerId;
        }
    }
 }
Gopal ojha
  • 2.2k
  • 2
  • 12
  • 21