The usage limit policy allows you to restrict how many times a session key can be used. This provides a simple but effective way to limit the total number of operations a session can perform, regardless of the operation type.
Security Consideration: Set conservative usage limits based on expected legitimate usage patterns to minimize potential abuse.
Copy
Ask AI
import { usersNexusClient } from "./client.ts";import { parseEther } from "viem";const createSessionsResponse = await usersNexusClient.grantPermission({ sessionRequestedInfo: [ { sessionPublicKey, actionPoliciesInfo: [ { contractAddress: "0x123", functionSelector: "0x456", // Limit total usage to 100 transactions usageLimit: BigInt(100), // Optional: Combine with other policies validUntil: BigInt(Date.now() + 7 * 24 * 60 * 60 * 1000) // 7 days } ] } ]});