Contract 0x95AE62E3E2261615970375CC8af8c7E6923627Fa

Contract Overview

Balance:
0 Ether
Txn Hash
Method
Block
From
To
Value
0x4a4261ee87f0c091466f4ca5bda273e7671f1e590a21a9d4c2a3491498f1dc3bStore87445262021-06-11 9:34:08388 days 15 hrs ago0x06b5959c3d8212a5718c4b5d6827aa7b2f29e2d5 IN  0x95ae62e3e2261615970375cc8af8c7e6923627fa0 Ether0.00004361
0xf3c278dbd0b2dacf381ed5a6052b8af748ae86982f25890c2d55398a4a5f039fStore84924882021-04-28 14:57:01432 days 10 hrs ago0x1bfdb5c6b6993a79e38b4c4e43759fd90ea2b839 IN  0x95ae62e3e2261615970375cc8af8c7e6923627fa0 Ether0.00004361
0x5382259f4875758705918a9e4a4f29cb94b9a647b80831b2c348b1caa78937ddStore Earliest84924832021-04-28 14:55:46432 days 10 hrs ago0x1bfdb5c6b6993a79e38b4c4e43759fd90ea2b839 IN  0x95ae62e3e2261615970375cc8af8c7e6923627fa0 Ether0.000043451
0x6969e8e6653cc9957ff1679e6cc61b5568b9715abd8041f9d82fc954113bc2a00x6080604083708132021-04-07 11:44:17453 days 13 hrs ago0x1bfdb5c6b6993a79e38b4c4e43759fd90ea2b839 IN  Create: BlockhashStore0 Ether0.0212456100
[ Download CSV Export 
Latest 1 internal transaction
Parent Txn Hash Block From To Value
0xb5e2bfd40e17a36eb2dbf651040966f3b00818aa989d494923a9d1edf91ccab296225442021-11-11 8:48:10235 days 16 hrs ago 0x6d5ba663ddca573557c8420256dc85f31d9762b0 0x95ae62e3e2261615970375cc8af8c7e6923627fa0 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BlockhashStore

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 1 : BlockhashStore.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

/**
 * @title BlockhashStore
 * @notice This contract provides a way to access blockhashes older than
 *   the 256 block limit imposed by the BLOCKHASH opcode.
 *   You may assume that any blockhash stored by the contract is correct.
 *   Note that the contract depends on the format of serialized Ethereum
 *   blocks. If a future hardfork of Ethereum changes that format, the
 *   logic in this contract may become incorrect and an updated version
 *   would have to be deployed.
 */
contract BlockhashStore {
    mapping(uint256 => bytes32) internal _sBlockhashes;

    /**
     * @notice stores blockhash of the earliest block still available through BLOCKHASH.
     */
    function storeEarliest() external {
        store(block.number - 256);
    }

    /**
     * @notice gets a blockhash from the store. If no hash is known, this function reverts.
     * @param n the number of the block whose blockhash should be returned
     */
    function getBlockhash(uint256 n) external view returns (bytes32) {
        bytes32 h = _sBlockhashes[n];
        require(h != 0x0, "blockhash not found in store");
        return h;
    }

    /**
     * @notice stores blockhash of a given block, assuming it is available through BLOCKHASH
     * @param n the number of the block whose blockhash should be stored
     */
    function store(uint256 n) public {
        bytes32 h = blockhash(n);
        require(h != 0x0, "blockhash(n) failed");
        _sBlockhashes[n] = h;
    }

    /**
     * @notice stores blockhash after verifying blockheader of child/subsequent block
     * @param n the number of the block whose blockhash should be stored
     * @param header the rlp-encoded blockheader of block n+1. We verify its correctness by checking
     *   that it hashes to a stored blockhash, and then extract parentHash to get the n-th blockhash.
     */
    function storeVerifyHeader(uint256 n, bytes memory header) public {
        require(
            keccak256(header) == _sBlockhashes[n + 1],
            "header has unknown blockhash"
        );

        // At this point, we know that header is the correct blockheader for block n+1.

        // The header is an rlp-encoded list. The head item of that list is the 32-byte blockhash of the parent block.
        // Based on how rlp works, we know that blockheaders always have the following form:
        // 0xf9____a0PARENTHASH...
        //   ^ ^   ^
        //   | |   |
        //   | |   +--- PARENTHASH is 32 bytes. rlpenc(PARENTHASH) is 0xa || PARENTHASH.
        //   | |
        //   | +--- 2 bytes containing the sum of the lengths of the encoded list items
        //   |
        //   +--- 0xf9 because we have a list and (sum of lengths of encoded list items) fits exactly into two bytes.
        //
        // As a consequence, the PARENTHASH is always at offset 4 of the rlp-encoded block header.

        bytes32 parentHash;
        assembly {
            parentHash := mload(add(header, 36)) // 36 = 32 byte offset for length prefix of ABI-encoded array
            //    +  4 byte offset of PARENTHASH (see above)
        }

        _sBlockhashes[n] = parentHash;
    }
}

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "evmVersion": "istanbul",
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"n","type":"uint256"}],"name":"getBlockhash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"n","type":"uint256"}],"name":"store","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"storeEarliest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"n","type":"uint256"},{"internalType":"bytes","name":"header","type":"bytes"}],"name":"storeVerifyHeader","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b506102e2806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80636057361d1461005157806383b6d6b714610070578063e9413d3814610078578063fadff0e1146100a7575b600080fd5b61006e6004803603602081101561006757600080fd5b5035610154565b005b61006e6101b0565b6100956004803603602081101561008e57600080fd5b50356101bf565b60408051918252519081900360200190f35b61006e600480360360408110156100bd57600080fd5b813591908101906040810160208201356401000000008111156100df57600080fd5b8201836020820111156100f157600080fd5b8035906020019184600183028401116401000000008311171561011357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610226945050505050565b80408061019e576040805162461bcd60e51b8152602060048201526013602482015272189b1bd8dada185cda0a1b8a4819985a5b1959606a1b604482015290519081900360640190fd5b60009182526020829052604090912055565b6101bd6101004303610154565b565b60008181526020819052604081205480610220576040805162461bcd60e51b815260206004820152601c60248201527f626c6f636b68617368206e6f7420666f756e6420696e2073746f726500000000604482015290519081900360640190fd5b92915050565b60008083600101815260200190815260200160002054818051906020012014610296576040805162461bcd60e51b815260206004820152601c60248201527f6865616465722068617320756e6b6e6f776e20626c6f636b6861736800000000604482015290519081900360640190fd5b602401516000918252602082905260409091205556fea264697066735822122065356e8a30b8193d43b1dee563f99569533ebdd0f2bbd887924080330dcd850a64736f6c634300060c0033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.