🤖Working with Agents
Overview
Initialize SDK
import { SomniaAgentKit, SOMNIA_NETWORKS } from 'somnia-agent-kit';
const kit = new SomniaAgentKit({
network: SOMNIA_NETWORKS.testnet,
contracts: {
agentRegistry: '0xC9f3452090EEB519467DEa4a390976D38C008347',
agentManager: '0x77F6dC5924652e32DBa0B4329De0a44a2C95691E',
agentExecutor: '0x157C56dEdbAB6caD541109daabA4663Fc016026e',
agentVault: '0x7cEe3142A9c6d15529C322035041af697B2B5129',
},
privateKey: process.env.PRIVATE_KEY, // Optional for read operations
});
await kit.initialize();Register Agent
Query Agents
Get Total Agents
Get Agent by ID
Get Agents by Owner
Get All Agents
Update Agent
Update Agent Info
Manage Agent Status
Set Agent Status
Transfer Ownership
Listen to Events
Agent Registered Event
Agent Updated Event
Agent Status Changed Event
Complete Example
Best Practices
1. Always Initialize SDK
2. Handle Errors
3. Check Agent Exists
4. Verify Ownership
See Also
Last updated

