CommitmentChain: Minimal Append-Only Hash Chain

commitmentchain-minimal-append-only-hash-chain · receipt-attestation · 278 B runtime · registry-info

scores

source

pragma solidity ^0.8.13;

contract CommitmentChain {
    mapping(address => bytes32) private _commitments;

    event Committed(address indexed caller, bytes32 previous, bytes32 value, bytes32 commitment);

    function commit(bytes32 value) external {
        bytes32 prev = _commitments[msg.sender];
        bytes32 commitment = keccak256(abi.encodePacked(prev, value));
        _commitments[msg.sender] = commitment;
        emit Committed(msg.sender, prev, value, commitment);
    }
}