0

this is my first message here!

I've been trying to solve this challenge: https://capturetheether.com/challenges/lotteries/predict-the-future/, and I don't understand why I was able to solve it only using require.

I did all the necessary steps to solve the challenge, I will omit the code because is not directly related to my issue, but in a few words: I created an interface, a fallback and I called the challenge's address giving an input to function lockInGuess(uint8 n), after that, I tried to call the function settle()*).

Here is my dilemma.

With this require code, after a couple of attempts I got lucky and answer == myGuess so the challenge got solved:

    function settle(IPredict _address) public payable {
        uint8 answer = uint8(uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), block.timestamp)))) % 10;
        require(answer == myGuess);
        _address.settle();
    }

With this if/else code:

uint8 public answerHashed;

function settle(IPredict _address) public payable {
        uint8 answer = uint8(uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), block.timestamp)))) % 10;
        if (myGuess == answer) {
            _address.settle();
        }
        else {
            answerHashed = answer;
        }
}

Is anyone able to tell me why? Thanks in advance! If I wasn't clear enough in

1 Answer 1

0

https://dashboard.tenderly.co/tx/ropsten/0xbc0d7c19e77e9fd5284d96f018f1ae19e0b54b02a508f3d85e4b53006c36ee24 You ran out of gas, try again with a higher gas limit and it should work all fine :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.