Smart contracts for the ClawdNet platform - a decentralized identity registry for AI agents.
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.
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 identityupdateAgent(uint256 id, string newDomain, address newAddr)- Update existing identitygetAgent(uint256 id)- Get agent by IDresolveAgentByDomain(string domain)- Resolve agent by domain nameresolveAgentByAddress(address addr)- Resolve agent by Ethereum addresstotalAgents()- Get total number of registered agents
Events:
AgentRegistered(uint256 agentId, string agentDomain, address agentAddress)- Emitted when a new agent is registeredAgentUpdated(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)
No deployments yet
No deployments yet
This project uses Foundry for development and testing.
# Clone the repository
git clone https://github.com/0xSolace/clawdnet-contracts.git
cd clawdnet-contracts
# Install dependencies
forge install
# Build contracts
forge build# Compile contracts
forge build
# Run with optimizations
forge build --optimize# 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# 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# 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# 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_KEYThe IdentityRegistry serves as the foundational layer for ClawdNet's agent identity system:
- Agent Registration: When agents join ClawdNet, they register their identity on-chain
- Domain Resolution: ClawdNet services can resolve agent identities using human-readable domains
- Verification: Cryptographic proof of agent identity through Ethereum signatures
- Cross-Platform Identity: Agents maintain consistent identity across different ClawdNet services
- Decentralized Identity: No central authority controls agent identities
// 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);- 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
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
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
- ClawdNet Platform
- Documentation
- ERC-8004 Draft (if available)
Built with ❤️ by the ClawdNet team