Verified contractPartial
szfcMerkleRoot
Address0xae08937ca38979d6c2fbac7bf7b8af8176ab9065
- Balance
0 ETH
- Transactions
199
- Compiler
solc 0.5.2
- Same code
Only this contract
Details
- Compiler
- solc 0.5.2+commit.1df8f40c
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- Not stated
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 7,405,476
- Creation transaction
- 0xeadf2a2af5…1f82338880
szfcMerkleRoot.sol
pragma solidity ^0.5.2;
contract szfcMerkleRoot {
uint64 oneHour= 3600000;
address owner;
mapping(bytes32 => uint64) hash2timestamp;
mapping(uint64=> bytes32[]) public timestamp2hashes; //date -> merkle root hash
constructor() public {
owner = msg.sender;
}
function push(uint64 _timestamp, bytes32 _root) external{
require(msg.sender == owner);
require(checkTime(_timestamp));
require(hash2timestamp[_root] == 0);
//归结
uint64 hour_point = _timestamp - _timestamp % oneHour;
hash2timestamp[_root] = _timestamp;
bytes32[] storage hashes = timestamp2hashes[hour_point];
hashes.push(_root);
}
function getAllHashes(uint64 _timestamp) external view returns(bytes32[] memory){
uint64 hour_point = _timestamp - _timestamp % oneHour;
bytes32[] storage hashes = timestamp2hashes[hour_point];
return hashes;
}
function getLastHash(uint64 _timestamp) public view returns(bytes32){
uint64 hour_point = _timestamp - _timestamp % oneHour;
bytes32[] storage hashes = timestamp2hashes[hour_point];
if( hashes.length > 0 ) {
return hashes[hashes.length-1];
}
return 0x00;
}
function getTimestamp(bytes32 _root) external view returns(uint64){
return hash2timestamp[_root];
}
function getOwner() external view returns(address){
return owner;
}
function checkTime(uint64 _timestamp) private view returns (bool) {
return ( _timestamp < now * 1000 );
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.