|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity ^0.8.23; |
| 3 | + |
| 4 | +// interfaces |
| 5 | + |
| 6 | +// libraries |
| 7 | + |
| 8 | +// contracts |
| 9 | + |
| 10 | +/// @title IIdentityRegistryBase |
| 11 | +/// @notice Base interface for ERC-8004 compliant agent identity registry |
| 12 | +/// @dev Defines core data structures, events, and errors for agent registration and metadata management |
| 13 | +interface IIdentityRegistryBase { |
| 14 | + /// @notice Metadata entry for storing additional on-chain agent information |
| 15 | + /// @dev Used in batch metadata operations during agent registration |
| 16 | + struct MetadataEntry { |
| 17 | + /// @notice The metadata key identifier |
| 18 | + string metadataKey; |
| 19 | + /// @notice The metadata value stored as bytes |
| 20 | + bytes metadataValue; |
| 21 | + } |
| 22 | + |
| 23 | + /// @notice Emitted when a new agent is registered in the identity registry |
| 24 | + /// @param agentId The unique identifier (agentId) assigned to the agent |
| 25 | + /// @param agentUri The URI pointing to the agent's registration file |
| 26 | + /// @param owner The address that owns the agent identity |
| 27 | + event Registered(uint256 indexed agentId, string agentUri, address indexed owner); |
| 28 | + |
| 29 | + /// @notice Emitted when metadata is set or updated for an agent |
| 30 | + /// @param agentId The unique identifier of the agent |
| 31 | + /// @param indexedKey The metadata key as indexed parameter for efficient filtering |
| 32 | + /// @param metadataKey The metadata key as non-indexed parameter for reading |
| 33 | + /// @param metadataValue The metadata value stored as bytes |
| 34 | + event MetadataSet( |
| 35 | + uint256 indexed agentId, |
| 36 | + string indexed indexedKey, |
| 37 | + string metadataKey, |
| 38 | + bytes metadataValue |
| 39 | + ); |
| 40 | + |
| 41 | + /// @notice Emitted when an agent's URI is updated |
| 42 | + /// @param agentId The unique identifier of the agent |
| 43 | + /// @param agentUri The new URI pointing to the agent's registration file |
| 44 | + /// @param updatedBy The address that performed the update |
| 45 | + event UriUpdated(uint256 indexed agentId, string agentUri, address indexed updatedBy); |
| 46 | + |
| 47 | + /// @notice Thrown when caller is not authorized to perform the operation |
| 48 | + /// @dev Authorization requires being the owner, an approved operator, or approved for the specific token |
| 49 | + error IdentityRegistry__NotAuthorized(); |
| 50 | + |
| 51 | + /// @notice Thrown when attempting to access an agent that does not exist |
| 52 | + error IdentityRegistry__AgentDoesNotExist(); |
| 53 | + |
| 54 | + /// @notice Thrown when attempting an operation on an agent that is not registered |
| 55 | + error IdentityRegistry__AgentNotRegistered(); |
| 56 | + |
| 57 | + /// @notice Thrown when attempting to register an agent that is banned |
| 58 | + error IdentityRegistry__AgentBanned(); |
| 59 | + |
| 60 | + /// @notice Thrown when attempting to promote or register an agent that already has a promoted identity |
| 61 | + error IdentityRegistry__AgentAlreadyPromoted(); |
| 62 | +} |
| 63 | + |
| 64 | +/// @title IIdentityRegistry |
| 65 | +/// @notice ERC-8004 compliant agent identity registry interface |
| 66 | +/// @dev Extends ERC-721 with agent registration, metadata management, and URI storage capabilities. |
| 67 | +/// Each agent is uniquely identified globally by: namespace (eip155), chainId, identityRegistry address, and agentId. |
| 68 | +/// The tokenURI resolves to an agent registration file containing endpoints, capabilities, and trust model information. |
| 69 | +interface IIdentityRegistry is IIdentityRegistryBase { |
| 70 | + /// @notice Register a new agent identity without initial URI or metadata |
| 71 | + /// @dev Mints a new ERC-721 token to msg.sender. URI can be set later via setAgentUri. |
| 72 | + /// @return agentId The unique identifier assigned to the newly registered agent |
| 73 | + function register() external returns (uint256 agentId); |
| 74 | + |
| 75 | + /// @notice Register a new agent identity with a tokenURI |
| 76 | + /// @dev Mints a new ERC-721 token to msg.sender and sets the tokenURI |
| 77 | + /// @param agentUri The URI pointing to the agent's registration file (e.g., ipfs://cid or https://domain.com/agent.json) |
| 78 | + /// @return agentId The unique identifier assigned to the newly registered agent |
| 79 | + function register(string calldata agentUri) external returns (uint256 agentId); |
| 80 | + |
| 81 | + /// @notice Register a new agent identity with tokenURI and metadata |
| 82 | + /// @dev Mints a new ERC-721 token to msg.sender, sets the tokenURI, and stores metadata entries. |
| 83 | + /// This is the most complete registration method for agents with immediate metadata. |
| 84 | + /// @param agentUri The URI pointing to the agent's registration file |
| 85 | + /// @param metadata Array of metadata entries to store as on-chain metadata |
| 86 | + /// @return agentId The unique identifier assigned to the newly registered agent |
| 87 | + function register( |
| 88 | + string calldata agentUri, |
| 89 | + MetadataEntry[] calldata metadata |
| 90 | + ) external returns (uint256 agentId); |
| 91 | + |
| 92 | + /// @notice Retrieve metadata value for a specific agent and metadataKey |
| 93 | + /// @dev Returns empty bytes if the metadataKey does not exist |
| 94 | + /// @param agentId The unique identifier of the agent |
| 95 | + /// @param metadataKey The metadata key to retrieve |
| 96 | + /// @return The metadata value stored as bytes |
| 97 | + function getMetadata( |
| 98 | + uint256 agentId, |
| 99 | + string memory metadataKey |
| 100 | + ) external view returns (bytes memory); |
| 101 | + |
| 102 | + /// @notice Set or update metadata for a specific agent |
| 103 | + /// @dev Only callable by the agent owner, approved operator, or token-specific approved address. |
| 104 | + /// Emits MetadataSet event. |
| 105 | + /// @param agentId The unique identifier of the agent |
| 106 | + /// @param metadataKey The metadata key to set |
| 107 | + /// @param metadataValue The metadata value to store as bytes |
| 108 | + function setMetadata( |
| 109 | + uint256 agentId, |
| 110 | + string memory metadataKey, |
| 111 | + bytes memory metadataValue |
| 112 | + ) external; |
| 113 | + |
| 114 | + /// @notice Update the tokenURI for an agent |
| 115 | + /// @dev Only callable by the agent owner, approved operator, or token-specific approved address. |
| 116 | + /// Emits UriUpdated event. Useful when agent registration data changes. |
| 117 | + /// @param agentId The unique identifier of the agent |
| 118 | + /// @param agentUri The new URI pointing to the agent's updated registration file |
| 119 | + function setAgentUri(uint256 agentId, string calldata agentUri) external; |
| 120 | + |
| 121 | + /// @notice Get the tokenURI for an agent |
| 122 | + /// @dev Returns the URI pointing to the agent's registration file. |
| 123 | + /// Reverts if the token does not exist. |
| 124 | + /// @param agentId The unique identifier of the agent (ERC-721 tokenId) |
| 125 | + /// @return The URI string pointing to the agent's registration file |
| 126 | + function tokenURI(uint256 agentId) external view returns (string memory); |
| 127 | +} |
0 commit comments