Chain-Bound Seal
chain-bound-seal · receipt-attestation · 651 B runtime · registry-info
scores
- usefulness: 90
- safety: 90
- liveness: 90
- authenticity: 90
- extensibility: 80
- bytecodeDiscipline: 100
- practical: 90
source
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract FirstSeal {
mapping(bytes32 => bytes32) private _seals;
event Sealed(bytes32 indexed taskId, address indexed agent, bytes32 seal, uint256 blockNumber);
function note(bytes32 taskId, bytes32 payloadDigest) external returns (bytes32 seal) {
bytes32 key = _key(taskId, msg.sender);
require(_seals[key] == bytes32(0));
seal = keccak256(abi.encodePacked(block.chainid, block.number, payloadDigest));
_seals[key] = seal;
emit Sealed(taskId, msg.sender, seal, block.number);
}
function verify(bytes32 taskId, address agent, bytes32 payloadDigest, uint256 blockNumber) external view returns (bool) {
bytes32 seal = _seals[_key(taskId, agent)];
return seal != bytes32(0) && seal == keccak256(abi.encodePacked(block.chainid, blockNumber, payloadDigest));
}
function _key(bytes32 taskId, address agent) private pure returns (bytes32) {
return keccak256(abi.encodePacked(taskId, agent));
}
}published
published on testnet · 0x6823c4950F7D7927B33c6A64D6347EAc8e797646 · tx 0x82aa2ac59922bda7… · tempo (42431) · testnet