Skip to main content

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

ParameterDescription
agentAddress of the AI agent
expiresAtUnix timestamp when session expires
dailyLimitUSDMaximum daily spending in USD
perTxLimitUSDMaximum per-transaction spending
maxPositionSizePctMaximum position size (1-100%)
maxSlippageBpsMaximum slippage in basis points
allowedOperationsArray of allowed function selectors
allowedProtocolsArray 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);