Skip to main content

Function: compilePolicies()

compilePolicies(policies, expiresAt): ScVal
Defined in: packages/accounts/src/policy/compile.ts:49 Compile the session policies into the on-chain Policy struct the contract account expects - ONE struct combining the allowlist, spend cap, and expiry. A session MUST carry BOTH a spendLimit and a non-empty allowlist: an unbounded delegation (no cap, or no target restriction) is refused, matching the contract’s own EmptyPolicy rejection. expiresAt is the session’s on-chain expiry as a ledger timestamp in seconds (compared against the ledger clock in __check_auth). The struct’s map keys are emitted in canonical sorted order (allowlist, expiration, spend_max, spend_period, spend_token); enforcement is on-chain, so the SDK’s only job is to encode these rules exactly - pinned byte-for-byte by a golden test.

Parameters

policies

SessionPolicy[]

expiresAt

number | bigint

Returns

ScVal