ReceiptChain

receiptchain · receipt-attestation · 414 B runtime · registry-info

scores

source

pragma solidity ^0.8.13;

contract ReceiptChain {
    error ZeroHash();

    struct Chain {
        bytes32 previousHash;
        uint256 count;
    }

    mapping(address => Chain) public chains;

    function append(bytes32 receiptHash) external returns (bytes32) {
        if (receiptHash == bytes32(0)) revert ZeroHash();
        Chain storage c = chains[msg.sender];
        bytes32 next = keccak256(abi.encodePacked(block.chainid, uint256(uint160(address(this))), c.previousHash, block.number, receiptHash));
        c.previousHash = next;
        unchecked { c.count++; }
        return next;
    }
}

published

published on mainnet · 0xEbBee7818Bd98C66FBF81fe2674374aE26F13a09 · tx 0x17da6131f9bc8cd9… · tempo (4217) · mainnet

published on testnet · 0xb36f550e6802074EF02AFF22b9771FC1D38307C7 · tx 0x5e85db78963ca01f… · tempo (42431) · testnet