OZContext Rule Manager
Manages context rules for OpenZeppelin Smart Accounts.
Context rules define authorization requirements for different types of operations. Each rule specifies:
Context type: What operations does this rule apply to (default, call contract, create contract)
Name: A human-readable identifier for the rule
Signers: Who can authorize operations matching this context
Policies: What constraints apply (spending limits, time locks, multi-sig thresholds, etc.)
Valid until: Optional expiration ledger number
The smart account evaluates transactions against context rules to determine:
Which signers are required to authorize the transaction
Which policies must be satisfied for the transaction to execute
All state-changing methods accept an optional selectedSigners parameter for multi-signer authorization. When empty (default), the operation uses single-signer auth with the connected passkey. When non-empty, signatures are collected from all listed signers via OZMultiSignerManager.submitWithMultipleSigners.
Contract limits:
Maximum 15 signers per context rule
Maximum 5 policies per context rule
Example usage:
val contextMgr = kit.contextRuleManager
// Add a rule for token transfers requiring 2-of-3 multi-sig
val result = contextMgr.addContextRule(
contextType = ContextRuleType.CallContract(tokenContractAddress),
name = "TokenTransfers",
validUntil = null,
signers = listOf(signer1, signer2, signer3),
policies = mapOf(
thresholdPolicyAddress to thresholdScVal
)
)
// Get total count of context rules
val count = contextMgr.getContextRulesCount()
// Remove a context rule
val removeResult = contextMgr.removeContextRule(id = ruleId)Functions
Adds a new context rule to the smart account.
Retrieves all active context rules as raw ScVal objects.
Retrieves a specific context rule by its ID.
Retrieves the total number of context rules in the smart account.
Lists all active context rules as parsed objects.
Removes a context rule from the smart account.
Updates the name of an existing context rule.
Updates the expiration ledger of an existing context rule.