# Blockhash

Blockhash (opens new window) represents a hashed state of a block -- in fact, recursively including the states of all past blocks.

It's simple enough, but its API (opens new window) seems oddly enough. It is your job as a developer to use it securely!

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

contract Blockhash {
    mapping(string => bool) public completed;

    constructor(address _player) {
        _player;
    }

    function lastBlockhash(bytes32 _blockhash) external {
        require(blockhash(block.number - 1) == _blockhash);
        completed["last"] = true;
    }

    function currentBlockhash(bytes32 _blockhash) external {
        require(blockhash(block.number) == _blockhash);
        completed["current"] = true;
    }

    function genesisBlockhash(bytes32 _blockhash) external {
        require(blockhash(0) == _blockhash);
        completed["genesis"] = true;
    }

    function futureBlockhash(bytes32 _blockhash) external {
        require(blockhash(block.number + 1) == _blockhash);
        completed["future"] = true;
    }

    function solved() external returns (bool) {
        return completed["last"]
            && completed["current"]
            && completed["genesis"]
            && completed["future"];
    }
}