# Locked with Blockhash

Your account with 1 gwei (opens new window) is locked with the hash of a future block. Your job is to get back your fund from the smart contract by successfully invoking settle().

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

contract LockedWithBlockhash {
    address guesser;
    bytes32 guess;
    uint256 settlementBlockNumber;

    constructor(address _player) payable {
        require(msg.value == 1 gwei);
        _player;
    }

    function solved() public view returns (bool) {
        return address(this).balance == 0;
    }

    function lockInGuess(bytes32 hash) public payable {
        require(guesser == address(0));
        require(msg.value == 1 gwei);

        guesser = msg.sender;
        guess = hash;
        settlementBlockNumber = block.number + 1;
    }

    function settle() public {
        require(msg.sender == guesser);
        require(block.number > settlementBlockNumber);

        bytes32 answer = blockhash(settlementBlockNumber);

        guesser = address(0);
        if (guess == answer) {
            payable(msg.sender).transfer(2 gwei);
        }
    }
}