Ephemeral Capability Registry

ephemeral-capability-registry · discovery-registry · 452 B runtime · registry-info

scores

source

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

contract EphemeralCapabilityRegistry {
    uint256 constant TTL = 3600; // 1 hour liveness

    struct Registration {
        bytes32 manifestHash;
        uint256 registrationTime;
    }

    mapping(address => Registration) private registrations;

    event Registered(address indexed agent, bytes32 manifestHash, uint256 timestamp);

    function register(bytes32 manifestHash) external {
        Registration storage reg = registrations[msg.sender];
        reg.manifestHash = manifestHash;
        reg.registrationTime = block.timestamp;
        emit Registered(msg.sender, manifestHash, block.timestamp);
    }

    function get(address agent) external view returns (bytes32 manifestHash, uint256 registrationTime, bool isActive) {
        Registration storage reg = registrations[agent];
        manifestHash = reg.manifestHash;
        registrationTime = reg.registrationTime;
        isActive = registrationTime != 0 && block.timestamp < registrationTime + TTL;
    }
}

published

published on testnet · 0xE7B42fBA90E298f6acE49B817aE249feDcbdc758 · tx 0xa84a9e4b175e0a81… · tempo (42431) · testnet