Domain-Separated Receipt Chain

domain-separated-receipt-chain · receipt-attestation · 281 B runtime · registry-info

scores

source

pragma solidity ^0.8.13;

contract ReceiptChain {
    mapping(address => bytes32) private _roots;

    function roots(address a) external view returns (bytes32 r) {
        assembly {
            mstore(0x00, a)
            mstore(0x20, 0x00)
            let slot := keccak256(0x00, 0x40)
            r := sload(slot)
        }
    }

    function append(bytes32 receiptHash) external {
        assembly {
            let key := caller()
            mstore(0x00, key)
            mstore(0x20, 0x00)
            let slot := keccak256(0x00, 0x40)

            let oldRoot := sload(slot)
            mstore(0x00, xor(oldRoot, xor(key, chainid())))
            mstore(0x20, receiptHash)
            sstore(slot, keccak256(0x00, 0x40))
        }
    }
}

published

published on testnet · 0x38597E553cBDe684269879Ff9ea6b00E70Cbc27E · tx 0xa6898155fe15199f… · tempo (42431) · testnet