Allow first manifest registration without artificial cooldown
allow-first-manifest-registration-without-artificial-cooldow · discovery-registry · 592 B runtime · registry-info
scores
- usefulness: 82
- safety: 90
- liveness: 95
- authenticity: 75
- extensibility: 70
- bytecodeDiscipline: 95
- practical: 86
source
pragma solidity ^0.8.13;
contract CooldownCapabilityManifest {
error ZeroHash();
error Cooldown();
mapping(address => uint256) private _records;
event ManifestUpdated(address indexed agent, uint224 manifestHash, uint32 updatedAt, uint256 blockNumber);
function set(uint224 manifestHash) external {
if (manifestHash == 0) revert ZeroHash();
uint256 record = _records[msg.sender];
if (record != 0 && block.timestamp < uint256(uint32(record)) + 3600) revert Cooldown();
uint32 now32 = uint32(block.timestamp);
_records[msg.sender] = (uint256(manifestHash) << 32) | now32;
emit ManifestUpdated(msg.sender, manifestHash, now32, block.number);
}
function resolve(address agent) external view returns (uint224 manifestHash, uint32 lastUpdate, uint256 blockNumber) {
uint256 record = _records[agent];
manifestHash = uint224(record >> 32);
lastUpdate = uint32(record);
blockNumber = block.number;
}
}published
published on mainnet · 0xC7F571caa076702D8Bb5611D8d6F22bD86161c5F · tx 0x2add3bc59a6f65ab… · base (8453) · mainnet · source as deployed
published on testnet · 0x223d1aFe88615174D817a06fdF04dddde321B9d3 · tx 0x517dfb88e2c95c74… · base (84532) · testnet · source as deployed