# AgentRegistry

**AgentRegistry** is the decentralized directory service for discovering, auditing, and version-controlling autonomous agents. Built on ERC-7645, it anchors agent metadata (code hashes, compliance status, performance stats) to enable trustless integration of third-party agents into Web3 workflows like payrolls, cross-chain swaps, or DAO governance.

***

#### **Core Components**

**1. Registry Smart Contract**

* Stores agent profiles (ID, owner, code hash, version).
* Enforces ERC-7645 compliance via ZK-proof validation.

**2. Agent Metadata**

| Field           | Description                                   |
| --------------- | --------------------------------------------- |
| **ZK-Identity** | Proof of agent integrity (code hash + owner). |
| **Compliance**  | GDPR/MiCA certification status.               |
| **Uptime**      | Historical reliability (e.g., 99.99% SLA).    |

**3. Version Control**

* Semantic versioning (major.minor.patch) with rollback capabilities.

***

#### **Workflow**

```mermaid
sequenceDiagram  
    Developer->>AgentRegistry: Deploy Agent v2.1  
    AgentRegistry->>ZK-Prover: Validate Code Hash  
    ZK-Prover-->>AgentRegistry: Proof ✔️  
    AgentRegistry-->>Developer: AgentID: 0xAgent123  
    User->>AgentRegistry: Search "Payroll Agents"  
    AgentRegistry-->>User: 3 Agents (SLA 99.9%+)  
    User->>AgentRegistry: Invoke 0xAgent123  
```

***

#### **Logic Code Example**

```python
from agentgpt.registry import AgentRegistry  
from agentgpt.web3 import ERC7645, ZKProver  
from typing import Dict  

class AgentManager(AgentRegistry):  
    def __init__(self):  
        super().__init__(erc7645_address="0xRegistry")  
        self.prover = ZKProver()  

    def create_agent_profile(self, metadata: Dict) -> str:  
        # Validate agent code integrity  
        code_hash = self.prover.calculate_hash(metadata["bytecode"])  
        proof = self.prover.generate_proof(code_hash)  
        
        # Register on ERC-7645  
        tx_hash = self.erc7645.register(  
            metadata["owner"],  
            metadata["version"],  
            code_hash,  
            proof  
        )  
        return tx_hash  

    def update_agent(self, agent_id: str, new_metadata: Dict):  
        # Check ownership  
        if self.erc7645.get_owner(agent_id) != msg.sender:  
            raise PermissionError("Not agent owner")  
        
        # Update version and re-prove  
        code_hash = self.prover.calculate_hash(new_metadata["bytecode"])  
        proof = self.prover.generate_proof(code_hash)  
        self.erc7645.update(agent_id, new_metadata["version"], code_hash, proof)  

    def discover_agents(self, filters: Dict) -> List:  
        agents = []  
        for agent_id in self.erc7645.list_agents():  
            profile = self.erc7645.get_profile(agent_id)  
            if (profile["sla"] >= filters["min_sla"] and  
                profile["version"].startswith(filters["version"])):  
                agents.append(profile)  
        return agents  

# Usage  
manager = AgentManager()  
metadata = {  
    "owner": "0xDev",  
    "version": "1.2.0",  
    "bytecode": "0xabc...",  
    "sla": 99.99  
}  
tx_hash = manager.create_agent_profile(metadata)  

# Discover agents  
agents = manager.discover_agents({"min_sla": 99.9, "version": "1.x"})  
```

***

#### **Key Features**

**1. Permissionless Registration**

Agents self-register with cryptographic proof:

```python
proof = self.prover.generate_proof(bytecode)  
self.erc7645.register(sender, "1.0.0", code_hash, proof)  
```

**2. Semantic Versioning**

Enforce version discipline:

```python
assert version.match(r"^\d+\.\d+\.\d+$"), "Invalid semver"  
```

**3. Cross-Chain Discovery**

Query agents across 40+ chains via unified API:

```python
agents = registry.discover(chain="arbitrum", tags=["payroll"])  
```

***

#### **Enterprise Use Cases**

**1. Enterprise Agent Hub**

A multinational bank manages 1,200+ agents:

* Track versions, SLA compliance, and ownership.
* Auto-retire agents with <99% uptime.

**2. Audit & Compliance**

Regulators verify agent integrity via on-chain ZK-proofs.

***

#### **Performance Metrics**

| **Metric**                | **Result**      |
| ------------------------- | --------------- |
| Lookup Speed (10K Agents) | 0.8s p99        |
| SLA Enforcement           | 99.97%          |
| Registration Cost         | 0.023 ETH/agent |

***

#### **Implementation Guide**

**1. CLI Commands**

```bash
# Register agent  
agentgpt-cli register-agent \  
  --name "PayrollBot" \  
  --version "2.1.0" \  
  --bytecode ./build/agent.bin  

# Discover agents  
agentgpt-cli discover --sla 99.9 --chain polygon  
```

**2. Best Practices**

* Use deterministic agent IDs (`AgentRegistry.agentId(name, version)`).
* Publish breaking changes as new major versions.

***

#### **Limitations**

* **Centralization**: Initial reliance on ERC-7645 registry.
* **Cost**: \~$120/agent registration (ETH mainnet).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://agent-gpt.gitbook.io/agent-gpt/agentgpt-architectures/architectures-available/agentregistry.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
