Skip to main content
You can limit the amount of ERC20 tokens transferable through a session function. Attach the policy at the function level — it caps the cumulative amount across all uses of that function.
const session = toSession({
  chain: base,
  owners: {
    type: 'ecdsa',
    accounts: [sessionOwnerAccount],
  },
  permissions: [
    {
      abi: erc20Abi,
      address: usdcAddress,
      functions: {
        transfer: {
          spendingLimit: {
            token: usdcAddress,
            amount: parseUnits('10', 6),
          },
        },
      },
    },
  ],
})
This caps total USDC transfers within the session to 10 USDC.