πContracts Overview
The Somnia Agent Kit consists of four core smart contracts that work together to enable AI agent operations on the blockchain.
Core Contracts
AgentRegistry.sol
Manages agent registration, discovery, and metadata.
Key Functions:
registerAgent(name, description, ipfsMetadata, capabilities): Register new agentupdateAgent(agentId, name, description, ipfsMetadata, capabilities): Update agent infosetAgentStatus(agentId, isActive): Activate/deactivate agentgetAgent(agentId): Get agent detailsgetTotalAgents(): Get total agent countgetAgentsByOwner(owner): Get agents by ownertransferAgentOwnership(agentId, newOwner): Transfer ownership
Contract Address (Testnet): 0xC9f3452090EEB519467DEa4a390976D38C008347
AgentManager.sol
Handles task creation, assignment, and lifecycle management.
Key Functions:
createTask(agentId, taskData, { value }): Create new taskstartTask(taskId): Start task executioncompleteTask(taskId, result): Complete task with resultcancelTask(taskId): Cancel taskgetTask(taskId): Get task details
Task Status:
0- Pending1- InProgress2- Completed3- Cancelled
Contract Address (Testnet): 0x77F6dC5924652e32DBa0B4329De0a44a2C95691E
AgentVault.sol
Manages agent funds with daily limits and multi-token support.
Key Functions:
createVault(agent, dailyLimit): Create vault for agent (owner only)depositNative(agent): Deposit native tokensdepositToken(agent, token, amount): Deposit ERC20 tokenswithdrawNative(agent, recipient, amount): Withdraw native tokenswithdrawToken(agent, token, recipient, amount): Withdraw ERC20 tokensallowToken(agent, token): Enable ERC20 token (owner only)updateDailyLimit(agent, newLimit): Update daily limit (owner only)getNativeBalance(agent): Get native token balancegetTokenBalance(agent, token): Get ERC20 token balancegetDailyLimitInfo(agent): Get daily limit infoisVaultActive(agent): Check if vault is active
Important: Vault uses agent addresses (not IDs) for all operations.
Contract Address (Testnet): 0x7cEe3142A9c6d15529C322035041af697B2B5129
AgentExecutor.sol
Handles task execution with authorization and gas management.
Key Functions:
authorizeAgent(): Authorize agent for executionexecuteTask(): Execute agent taskgetExecution(): Get execution details
Contract Address (Testnet): 0x157C56dEdbAB6caD541109daabA4663Fc016026e
Contract Interactions
Quick Start
Initialize SDK
Register an Agent
Create a Task
Create a Vault
Development
Deploy Contracts
Verify Contracts
Run Tests
Network Information
Somnia Testnet
Chain ID: 50311
RPC URL: https://dream-rpc.somnia.network
Explorer: https://somnia-devnet.socialscan.io
Currency: STT (Somnia Test Token)
Somnia Mainnet
Coming soon
Related Documentation
Security Considerations
Private Keys - Never commit private keys to version control
Daily Limits - Set appropriate daily limits for vaults
Token Whitelist - Only allow trusted tokens in vaults
Owner Verification - Always verify ownership before sensitive operations
Gas Management - Ensure sufficient gas for operations
For more detailed information about each contract, see their individual documentation pages.
Last updated

