Policy Engine API
Building a Policy
import { PolicyBuilder } from '@brain-protocol/sdk';
const policy = new PolicyBuilder()
.setSpendLimit('1000 USDC/day')
.setAllowedAssets(['USDC', 'ETH'])
.setAllowedContracts(['0xUniswapV3', '0xAaveV3'])
.setTimeWindow('09:00', '21:00', 'UTC')
.setApprovalThreshold('1-of-1')
.build();
const policyHash = await client.policies.deploy(policy, account.address);Updating a Policy
// Updates take effect after on-chain confirmation
await client.policies.update(agent.agentId, {
spendLimit: '2000 USDC/day',
});Simulate an Action Against a Policy
Get Current Policy
Check Remaining Budget
Policy Fields Reference
Field
Type
Description
