Agent Update
Update an existing agent’s configuration and re-register the changes.
from agent0_sdk import SDKimport os
# Initialize SDKsdk = SDK( chainId=11155111, # Ethereum Sepolia testnet rpcUrl=os.getenv("RPC_URL"), signer=os.getenv("PRIVATE_KEY"), ipfs="pinata", pinataJwt=os.getenv("PINATA_JWT"))
# Load existing agentagent = sdk.loadAgent("11155111:123")
print(f"Current: {agent.name}")
# Update informationagent.updateInfo( name="Updated Agent Name", description="New description", image="https://example.com/new-image.png")
# Update endpointsagent.setMCP("https://new-mcp.example.com/")agent.setA2A("https://new-a2a.example.com/agent.json")
# Update walletagent.setAgentWallet("0xNewWalletAddress", chainId=11155111)
# Update metadataagent.setMetadata({ "version": "2.0.0", "new_field": "new_value"})
# Change statusagent.setActive(True)agent.setX402Support(True)
# Re-register (uploads new file, updates on-chain)agent.registerIPFS()
print(f"✅ Updated and re-registered: {agent.agentId}")
# Verify changesretrieved = sdk.getAgent(agent.agentId)print(f"Name: {retrieved.name}")print(f"Description: {retrieved.description}")import { SDK } from 'agent0-sdk';
async function main() { // Initialize SDK const sdk = new SDK({ chainId: 11155111, // Ethereum Sepolia testnet rpcUrl: process.env.RPC_URL || '', signer: process.env.PRIVATE_KEY, // Required for updates ipfs: 'pinata', pinataJwt: process.env.PINATA_JWT, });
// Load existing agent (async in TypeScript) const agentId = '11155111:123'; const agent = await sdk.loadAgent(agentId);
console.log(`Current: ${agent.name}`);
// Update information agent.updateInfo( 'Updated Agent Name', 'New description', 'https://example.com/new-image.png' );
// Update endpoints (async in TypeScript) await agent.setMCP('https://new-mcp.example.com/'); await agent.setA2A('https://new-a2a.example.com/agent.json');
// Update wallet agent.setAgentWallet('0xNewWalletAddress', 11155111);
// Update metadata agent.setMetadata({ version: '2.0.0', new_field: 'new_value', });
// Change status agent.setActive(true); agent.setX402Support(true);
// Re-register (uploads new file, updates on-chain) const registrationFile = await agent.registerIPFS();
console.log(`✅ Updated and re-registered: ${registrationFile.agentId}`);
// Verify changes (async in TypeScript) const retrieved = await sdk.getAgent(registrationFile.agentId!); console.log(`Name: ${retrieved.name}`); console.log(`Description: ${retrieved.description}`);}
main().catch(console.error);