// the rest of initialization is same as here: smart-sessions/execute-transactions-on-users-behalf
const EMPTY_RAW_RULE = {
condition: ParamCondition.EQUAL,
offset: 0n,
isLimited: false,
ref: "0x0000000000000000000000000000000000000000000000000000000000000000" as `0x${string}`,
usage: { limit: 0n, used: 0n }
}
const uniActionPolicyInfoUSDC = getUniversalActionPolicy({
valueLimitPerUse: maxUint256,
paramRules: {
length: 2n,
rules: [
// rule to restrict usdc transfer recepient
{
condition: ParamCondition.EQUAL,
isLimited: false,
offset: 0n,
ref: pad(recepientAddress),
usage: { limit: 0n, used: 0n }
},
// rule to restrict every transfer to be less than
// or equal to 3 usdc, and total spending limit of 100 usdc
{
condition: ParamCondition.LESS_THAN_OR_EQUAL,
isLimited: true,
offset: 32n,
ref: pad(toHex(parseUnits("3", 6))),
usage: { limit: parseUnits("100", 6), used: 0n }
},
// fill the rest of rules with the placeholder rule
// they do not matter since length above is 2
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE,
EMPTY_RAW_RULE
]
}
})
const sessionDetails =
await sessionMeeClient.grantPermissionTypedDataSign({
redeemer: redeemerAddress,
feeToken,
actions: [
{
actionTargetSelector: toFunctionSelector(
getAbiItem({ abi: erc20Abi, name: "transfer" })
),
actionPolicies: [uniActionPolicyInfoUSDC],
chainId: targetChain.id,
actionTarget: mcUSDC.addressOn(targetChain.id)
}
],
maxPaymentAmount: parseUnits("3", 6)
})