Today’s onchain agents face a fundamental challenge: they need to transact, but users don’t trust them with private keys.Traditional solutions are broken:
Smart Sessions let users grant scoped, time-limited, revocable permissions to your agent. The agent can act autonomously within those bounds—enforced by smart contracts, not trust.
User grants permission → Agent acts within limits → Smart contract enforces rules
Automate recurring payments, subscriptions, and payroll.
// Agent can send up to 100 USDC// Only to merchant address 0x...// expires in 1 year and only 12 payments are allowed// Chargeable on day one of the monthconst dayOneTimeframePolicy = mcNexus.buildActionPolicy({ type: "timeframe", validAfter: ..., // unix-timestamp Eg: 1-1-2026 00:00:00 in unix timestamp validUntil: ... // unix-timestamp Eg: 1-1-2026 23:59:59 in unix timestamp});// Used only once per monthconst usagePolicy = mcNexus.buildActionPolicy({ type: "usageLimit", limit: 1n});// Only specific recipient and specific amountconst paymentPolicy = mcNexus.buildActionPolicy({ type: "universal", rules: [ // Only send to merchant { condition: "equal", calldataOffset: calldataArgument(1), comparisonValue: MERCHANT }, // Max 100 USDC per payment { condition: "lessThanOrEqual", calldataOffset: calldataArgument(2), comparisonValue: parseUnits("100", 6), } ], // Configure spending limit for native token valueLimitPerUse: 0n,});const monthOnePaymentAction = mcNexus.buildSessionAction({ type: "transfer", data: { chainIds: [8453, 10], contractAddress: USDC, policies: [dayOneTimeframePolicy, usagePolicy, paymentPolicy] }});// 10 similar actions for 10 monthsconst monthTwelvePaymentAction = mcNexus.buildSessionAction({ type: "transfer", data: { chainIds: [8453, 10], contractAddress: USDC, policies: [dayOneTimeframePolicy, usagePolicy, paymentPolicy] }});// 12 actions which can be executed only once per month on day one for a year.const permissions = { actions: [monthOnePaymentAction, ..., monthTwelvePaymentAction]};
Best policies: Universal Action + Usage Limit + Timeframe
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";const agentKey = generatePrivateKey();const agentSigner = privateKeyToAccount(agentKey);// Store agentKey securely in your backend