Skip to main content
The call policy filters transactions by calldata and ETH value. In v2 sessions, you express it as ABI-driven parameter rules on a permission’s function — the SDK reads the function selector and parameter offsets from the ABI for you.

Conditions

Available conditions:
  • equal (x=Ax = A)
  • greater than (x>Ax > A)
  • less than (x<Ax < A)
  • greater than or equal (xAx \geq A)
  • less than or equal (xAx \leq A)
  • not equal (xAx \neq A)
  • in range (AxBA \leq x \leq B)

Usage

To restrict an ERC20 transfer to a single recipient:
const receiver = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'

const session = toSession({
  chain: base,
  owners: {
    type: 'ecdsa',
    accounts: [sessionOwnerAccount],
  },
  permissions: [
    {
      abi: erc20Abi,
      address: usdcAddress,
      functions: {
        transfer: {
          params: {
            recipient: { condition: 'equal', value: receiver },
          },
        },
      },
    },
  ],
})
Reference parameters by name — the SDK looks them up in the ABI. Only static types are supported (address, bool, uint*, int*, bytes1bytes32).

Param accumulator

Cap the total accumulated value of a param across all session uses with usageLimit. Useful for capping cumulative spend across calls.
const session = toSession({
  chain: base,
  owners: {
    type: 'ecdsa',
    accounts: [sessionOwnerAccount],
  },
  permissions: [
    {
      abi: erc20Abi,
      address: usdcAddress,
      functions: {
        transfer: {
          params: {
            amount: {
              condition: 'lessThan',
              value: parseUnits('10', 6),
              usageLimit: parseUnits('50', 6),
            },
          },
        },
      },
    },
  ],
})
This caps each transfer at 10 USDC and the total across the session lifetime at 50 USDC.

Value limit

To cap the ETH value sent on a single call, use valueLimitPerUse at the function level:
const session = toSession({
  chain: base,
  owners: {
    type: 'ecdsa',
    accounts: [sessionOwnerAccount],
  },
  permissions: [
    {
      abi: vaultAbi,
      address: vaultAddress,
      functions: {
        depositEth: {
          valueLimitPerUse: parseUnits('0.1', 18),
        },
      },
    },
  ],
})
This limits the value per call to 0.1 ETH.