Value Limit Policy
The value limit policy allows you to set maximum transaction value limits for native token (ETH) transfers. This provides granular control over how much ETH can be spent in a single transaction or across all transactions within the session.
⚠️ Security Consideration: While more restrictive than sudo, ensure limits are set appropriately for your use case to minimize potential losses.
valueLimit.ts
import { usersNexusClient } from "./client.ts";
import { parseEther } from "viem";
const createSessionsResponse = await usersNexusClient.grantPermission({
sessionRequestedInfo: [
{
sessionPublicKey,
// sessionValidUntil: number
// sessionValidAfter: number
// chainIds: bigint[]
actionPoliciesInfo: [
{
abi: PaymentAbi, // Using the full contract ABI will parse it to individual function selectors under the hood
contractAddress: "0x...",
valueLimit: parseEther("1.0") // 1 ETH limit per transaction
}
]
}
]
})
Common Use Cases
- DeFi Operations: Limit maximum trade sizes or liquidity provisions
- Recurring Payments: Cap periodic payment amounts
- Treasury Management: Control spending limits for organizational funds
- Gas Fee Management: Set upper bounds for transaction fees
- Automated Trading: Implement safety limits for trading bots
- Subscription Services: Cap maximum payment amounts for subscriptions
Best Practices
- Conservative Limits: Start with lower limits and adjust based on usage patterns
- Multiple Tiers: Implement different limits for different operation types
- Cumulative Tracking: Consider both per-transaction and total session limits
- Market Volatility: Account for potential price fluctuations when setting limits
- Regular Reviews: Periodically assess and adjust limits based on needs
- Emergency Stops: Include mechanisms to pause operations if unusual patterns detected
- Combine with Time Limits: Use time-based restrictions to further control exposure