compliance / polygon /contracts /HashLogger.sol
VeuReu's picture
Upload 13 files
92b0172 verified
raw
history blame contribute delete
978 Bytes
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract HashLogger {
struct Entry {
bytes32 hash;
uint256 timestamp;
}
Entry[] public entries;
event HashLogged(bytes32 indexed hash, uint256 timestamp);
address public owner;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "Not authorized");
_;
}
function logHash(bytes32 hash) external onlyOwner {
uint256 ts = block.timestamp;
entries.push(Entry(hash, ts));
emit HashLogged(hash, ts);
}
function getEntryCount() external view returns (uint256) {
return entries.length;
}
function getEntry(uint256 index) external view returns (bytes32, uint256) {
require(index < entries.length, "Index out of range");
Entry storage e = entries[index];
return (e.hash, e.timestamp);
}
}