Contract Overview
Balance:
0 MATIC
MATIC Value:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0xe582c06cba3c98129f3124ea21aed5bc10290419cf203be71abc67ae8f4e06a0 | 0x60806040 | 24266935 | 148 days 18 mins ago | 0x42c1bbf9c3a2daaec18c78eb68847693d5279968 | IN | Create: BlockhashStore | 0 MATIC | 0.00849824 |
[ Download CSV Export ]
Contract Name:
BlockhashStore
Compiler Version
v0.6.12+commit.27d51765
Contract Source Code (Solidity)
/** *Submitted for verification at polygonscan.com on 2022-01-28 */ // File: contracts/dev/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; } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"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"}]
Contract Creation Code
608060405234801561001057600080fd5b506102e2806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80636057361d1461005157806383b6d6b714610070578063e9413d3814610078578063fadff0e1146100a7575b600080fd5b61006e6004803603602081101561006757600080fd5b5035610154565b005b61006e6101b0565b6100956004803603602081101561008e57600080fd5b50356101bf565b60408051918252519081900360200190f35b61006e600480360360408110156100bd57600080fd5b813591908101906040810160208201356401000000008111156100df57600080fd5b8201836020820111156100f157600080fd5b8035906020019184600183028401116401000000008311171561011357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610226945050505050565b80408061019e576040805162461bcd60e51b8152602060048201526013602482015272189b1bd8dada185cda0a1b8a4819985a5b1959606a1b604482015290519081900360640190fd5b60009182526020829052604090912055565b6101bd6101004303610154565b565b60008181526020819052604081205480610220576040805162461bcd60e51b815260206004820152601c60248201527f626c6f636b68617368206e6f7420666f756e6420696e2073746f726500000000604482015290519081900360640190fd5b92915050565b60008083600101815260200190815260200160002054818051906020012014610296576040805162461bcd60e51b815260206004820152601c60248201527f6865616465722068617320756e6b6e6f776e20626c6f636b6861736800000000604482015290519081900360640190fd5b602401516000918252602082905260409091205556fea264697066735822122093bf2316716fce0edb8ce6d5429adeab75cd94972e02ac9d04521394ba951f6f64736f6c634300060c0033
Deployed ByteCode Sourcemap
603:2722:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1459:158;;;;;;;;;;;;;;;;-1:-1:-1;1459:158:0;;:::i;:::-;;801:78;;;:::i;1074:191::-;;;;;;;;;;;;;;;;-1:-1:-1;1074:191:0;;:::i;:::-;;;;;;;;;;;;;;;;2009:1313;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2009:1313:0;;-1:-1:-1;2009:1313:0;;-1:-1:-1;;;;;2009:1313:0:i;1459:158::-;1515:12;;1546:8;1538:40;;;;;-1:-1:-1;;;1538:40:0;;;;;;;;;;;;-1:-1:-1;;;1538:40:0;;;;;;;;;;;;;;;1589:13;:16;;;;;;;;;;;:20;1459:158::o;801:78::-;846:25;867:3;852:12;:18;846:5;:25::i;:::-;801:78::o;1074:191::-;1130:7;1162:16;;;;;;;;;;;1197:8;1189:49;;;;;-1:-1:-1;;;1189:49:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;1256:1;1074:191;-1:-1:-1;;1074:191:0:o;2009:1313::-;2129:13;:20;2143:1;2147;2143:5;2129:20;;;;;;;;;;;;2118:6;2108:17;;;;;;:41;2086:119;;;;;-1:-1:-1;;;2086:119:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;3134:2;3122:15;3116:22;3049:18;3285:16;;;;;;;;;;;:29;2009:1313::o
Swarm Source
ipfs://93bf2316716fce0edb8ce6d5429adeab75cd94972e02ac9d04521394ba951f6f
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.