Skip to content

0xSolace/clawdnet-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClawdNet Contracts

MIT License Foundry Solidity

Smart contracts for the ClawdNet platform - a decentralized identity registry for AI agents.

Overview

ClawdNet Contracts provides the on-chain infrastructure for agent identity management and verification. The core contract implements a draft of ERC-8004, providing a standardized way to register, resolve, and manage AI agent identities on the blockchain.

Contract Overview

IdentityRegistry

The IdentityRegistry contract is a singleton deployed per chain that manages agent identities through domain-to-address mappings.

Key Features:

  • Unique Identity Registration: Each agent gets a unique ID, domain, and address mapping
  • Dual Resolution: Resolve agents by domain name or Ethereum address
  • Self-Sovereign Updates: Only agents can update their own identity information
  • Domain Uniqueness: Prevents domain squatting and conflicts
  • Address Uniqueness: Each Ethereum address can only register one agent identity

Key Functions:

  • newAgent(string domain, address addr) - Register a new agent identity
  • updateAgent(uint256 id, string newDomain, address newAddr) - Update existing identity
  • getAgent(uint256 id) - Get agent by ID
  • resolveAgentByDomain(string domain) - Resolve agent by domain name
  • resolveAgentByAddress(address addr) - Resolve agent by Ethereum address
  • totalAgents() - Get total number of registered agents

Events:

  • AgentRegistered(uint256 agentId, string agentDomain, address agentAddress) - Emitted when a new agent is registered
  • AgentUpdated(uint256 agentId, string previousDomain, string newDomain, address previousAddress, address newAddress) - Emitted when an agent is updated

Security Considerations:

  • Only the agent's registered address can update its identity
  • Domains and addresses must be unique across the registry
  • Zero addresses and empty domains are invalid
  • Self-registration required (msg.sender must equal agentAddress)

Deployment Addresses

Mainnet

No deployments yet

Testnets

No deployments yet

Installation

This project uses Foundry for development and testing.

Prerequisites

Setup

# Clone the repository
git clone https://github.com/0xSolace/clawdnet-contracts.git
cd clawdnet-contracts

# Install dependencies
forge install

# Build contracts
forge build

Build

# Compile contracts
forge build

# Run with optimizations
forge build --optimize

Testing

# Run all tests
forge test

# Run tests with verbosity
forge test -vvv

# Run specific test file
forge test --match-path test/IdentityRegistry.t.sol

# Run with gas reporting
forge test --gas-report

Deployment

Local Development

# Start local node
anvil

# Deploy to local network
forge script script/Deploy.s.sol:Deploy --rpc-url http://localhost:8545 --private-key $PRIVATE_KEY --broadcast

Testnet Deployment

# Deploy to Sepolia
forge script script/Deploy.s.sol:Deploy --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY

# Deploy to other testnets
forge script script/Deploy.s.sol:Deploy --rpc-url $TESTNET_RPC_URL --private-key $PRIVATE_KEY --broadcast

Mainnet Deployment

# Deploy to mainnet (use with caution)
forge script script/Deploy.s.sol:Deploy --rpc-url $MAINNET_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY

Integration with ClawdNet

The IdentityRegistry serves as the foundational layer for ClawdNet's agent identity system:

  1. Agent Registration: When agents join ClawdNet, they register their identity on-chain
  2. Domain Resolution: ClawdNet services can resolve agent identities using human-readable domains
  3. Verification: Cryptographic proof of agent identity through Ethereum signatures
  4. Cross-Platform Identity: Agents maintain consistent identity across different ClawdNet services
  5. Decentralized Identity: No central authority controls agent identities

Usage Examples

// Register a new agent
uint256 agentId = identityRegistry.newAgent("myagent.clawdnet", agentWallet);

// Resolve agent by domain
(uint256 id, string memory domain, address addr) = identityRegistry.resolveAgentByDomain("myagent.clawdnet");

// Update agent information (only by the agent itself)
identityRegistry.updateAgent(agentId, "newname.clawdnet", newWalletAddress);

Security Considerations

  • Self-Sovereign Identity: Agents have full control over their identity updates
  • No Admin Functions: The registry has no admin or owner - it's fully decentralized
  • Immutable Core: Once deployed, the core logic cannot be changed
  • Gas Optimizations: Uses unchecked arithmetic where safe for gas efficiency
  • Input Validation: Comprehensive validation of domains and addresses

Development

Project Structure

src/
├── IdentityRegistry.sol          # Main registry contract
├── interfaces/
│   └── IIdentityRegistry.sol     # Registry interface
└── libraries/                    # Utility libraries

script/
└── Deploy.s.sol                  # Deployment scripts

test/
└── IdentityRegistry.t.sol        # Contract tests

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links


Built with ❤️ by the ClawdNet team

About

Smart contracts for ClawdNet - On-chain identity and reputation

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors