Create Your First Agent
Create Your First Agent
Defining Agent Metadata
{
"name": "trading-agent-v1",
"description": "DeFi trading agent with risk controls",
"capabilities": ["swap", "lend", "borrow"],
"version": "1.0.0",
"owner": "0xYourAddress"
}Creating the Agent
import { BrainClient, PolicyBuilder } from '@brain-protocol/sdk';
const policy = new PolicyBuilder()
.setSpendLimit('500 USDC/day')
.setAllowedAssets(['USDC', 'ETH', 'WBTC'])
.setAllowedContracts(['0xUniswapV3', '0xAaveV3'])
.setTimeWindow('09:00', '21:00', 'UTC')
.setApprovalThreshold('1-of-1')
.build();
const agent = await client.agents.deploy({
accountAddress: account.address,
name: 'trading-agent-v1',
metadataUri: 'ipfs://QmYourMetadataHash',
policy,
});
console.log('Agent deployed:', {
agentId: agent.agentId,
executionAddress: agent.executionAddress,
policyHash: agent.policyHash,
});Pausing and Revoking Agents
Agent Status Reference
Status
Description
Last updated
