Session Management
Control what AI agents can do with session-based permissions.
Creating Sessions
const tx = await client.createSession({
agent: agentAddress,
expiresAt: Math.floor(Date.now() / 1000) + 86400, // 24 hours
dailyLimitUSD: 1000n * 10n**18n, // $1000 daily
perTxLimitUSD: 100n * 10n**18n, // $100 per tx
maxPositionSizePct: 20, // Max 20% of vault
maxSlippageBps: 100, // 1% max slippage
maxLeverage: 1,
allowedOperations: ['0x...'], // Function selectors
allowedProtocols: ['0x...'], // Protocol addresses
});
Session Parameters
| Parameter | Description |
|---|---|
agent | Address of the AI agent |
expiresAt | Unix timestamp when session expires |
dailyLimitUSD | Maximum daily spending in USD |
perTxLimitUSD | Maximum per-transaction spending |
maxPositionSizePct | Maximum position size (1-100%) |
maxSlippageBps | Maximum slippage in basis points |
allowedOperations | Array of allowed function selectors |
allowedProtocols | Array of allowed protocol addresses |
Checking Sessions
// Check if agent has active session
const isActive = await client.hasActiveSession(agentAddress);
// Get session details
const session = await client.getSession(agentAddress);
console.log('Expires:', new Date(session.expiresAt * 1000));
console.log('Daily spent:', session.dailySpentUSD);
Revoking Sessions
await client.revokeSession(agentAddress);