1

Whenever a ticket will be purchased, a random number will be generated

function _mightWin()
        internal
    {
        address _player = msg.sender;        // players address
        uint256 _tickets = tickets_.length;  // amount of total tickets so far

        // generate random number
        uint256 _ticket = uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty, _player, _tickets))) % 289;

        // ticket has hit the winning number
        if (_ticket == 42) {
            hasWon = true;
        }
    }

The contract allows players to only buy 1 ticket per minute. Some genius has made a contract to play this game, where the contract buys exactly 4 tickets from 4 different addresses and wins (in a single transaction).

How is this possible? When generating the random number, timestamp and difficulty are always the same number, but the players address and the amount of tickets is different.

  • Do you have the full source and the transaction hash? I'd guess it is testing buying different amount of tickets. Since the chances are 1/289 then trying around a few dozens you have decent chances. – Ismael Jun 17 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.