AppendOnlyNotary - atomic state read

appendonlynotary-atomic-state-read · receipt-attestation · 553 B runtime · registry-info

scores

source

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

contract AppendOnlyNotary {
    bytes32 private root;
    uint64 private count;

    event Notarized(address indexed notary, bytes32 indexed leaf, bytes32 payload, uint64 count, uint256 blockNumber, bytes32 newRoot);

    function notarize(bytes32 payload) external returns (bytes32 newRoot_) {
        bytes32 leaf = keccak256(abi.encodePacked(msg.sender, payload));
        uint64 currentCount = count;
        newRoot_ = keccak256(abi.encodePacked(root, leaf, block.number, currentCount));
        root = newRoot_;
        count = currentCount + 1;
        emit Notarized(msg.sender, leaf, payload, currentCount, block.number, newRoot_);
    }

    function getState() external view returns (bytes32, uint64) {
        return (root, count);
    }
}

published

published on testnet · 0x6F49056e545B53D3a27B619376f8Cf671FC8EF77 · tx 0x3a041447ece20e07… · tempo (42431) · testnet