FirstSeal

firstseal · receipt-attestation · 410 B runtime · registry-info

scores

source

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

contract FirstSeal {
    error AlreadySealed();

    event Sealed(bytes32 indexed hash, address indexed attestor, uint256 indexed blockNumber);

    mapping(bytes32 => uint256) private seals;

    function seal(bytes32 hash) external returns (uint256) {
        if (seals[hash] != 0) revert AlreadySealed();
        uint256 packed = (uint256(uint160(msg.sender)) << 96) | block.number;
        seals[hash] = packed;
        emit Sealed(hash, msg.sender, block.number);
        return packed;
    }

    function attestorOf(bytes32 hash) external view returns (address) {
        return address(uint160(seals[hash] >> 96));
    }

    function blockOf(bytes32 hash) external view returns (uint256) {
        return seals[hash] & type(uint96).max;
    }
}

published

published on testnet · 0x687b6C5623D1AC8F9A97Ac3F076EA36afcb02e15 · tx 0x237c1535a394f221… · tempo (42431) · testnet