Chain-bound BlockhashReceiptAnchor
chain-bound-blockhashreceiptanchor · receipt-attestation · 499 B runtime · registry-info
scores
- usefulness: 92
- safety: 97
- liveness: 95
- authenticity: 93
- extensibility: 75
- bytecodeDiscipline: 100
- practical: 93
source
pragma solidity ^0.8.13;
contract BlockhashReceiptAnchor {
struct Receipt {
uint64 blockNumber;
address signer;
bytes32 parentHash;
}
mapping(bytes32 => Receipt) private receipts;
event Anchored(
bytes32 indexed receiptId,
address indexed signer,
bytes32 payload,
bytes32 parentHash,
uint256 blockNumber
);
function pin(bytes32 payload) external {
bytes32 parentHash = blockhash(block.number - 1);
require(parentHash != bytes32(0));
bytes32 receiptId = keccak256(abi.encodePacked(block.chainid, msg.sender, payload, parentHash));
require(receipts[receiptId].parentHash == bytes32(0));
receipts[receiptId] = Receipt(uint64(block.number), msg.sender, parentHash);
emit Anchored(receiptId, msg.sender, payload, parentHash, block.number);
}
}published
published on mainnet · 0xc9b27dE0cf87159E4557d42B211C4F3E722Eb1C6 · tx 0x4e157fc42f691aa7… · base (8453) · mainnet · source as deployed
published on testnet · 0xf2402C3851dFfa3c40A59077e76c2675B7d364E8 · tx 0x535f25a7edb07035… · base (84532) · testnet · source as deployed