createSpendingPolicy
このコンテンツはまだ日本語訳がありません。
createSpendingPolicy(
params):SpendingPolicy
Defined in: src/policy/spending-policy.ts:188
Validate + normalize a SpendingPolicy. Checksums all addresses
(getAddress), de-dupes the recipient allowlist (shared
normalizeRecipientAllowlist; [] stays deny-all), rejects an empty
perToken (deny-closed), a non-positive maxPerSign/cumulativeCap, a
cumulativeCap < maxPerSign, and duplicate tokens. Throws
SpendingPolicyConfigError on violation.
Parameters
params
Returns
Example
const policy = createSpendingPolicy({ session: { id: conversationId, notAfter: BigInt(deadline) }, perToken: [{ token: JPYC, maxPerSign: 1_000n, cumulativeCap: 10_000n }], recipientAllowlist: [merchant],});