remove Policy
Removes a policy from a context rule by its ID.
Uninstalls the policy with the given ID from the specified context rule. The policy contract remains deployed on the network but is no longer evaluated for this context rule. The policy ID is assigned by the contract when the policy is added and is available via ParsedContextRule.policyIds after fetching the context rule.
Flow:
Validates that a wallet is connected
Builds contract invocation for remove_policy
Submits transaction via transactionOps (handles simulation, signing, polling)
IMPORTANT: This operation requires the connected wallet to have authorization on the smart account. The user will be prompted for biometric authentication to sign the transaction.
Return
TransactionResult indicating success or failure
Parameters
The context rule ID to remove the policy from (0 for Default rule)
The on-chain policy ID assigned by the contract (available from ParsedContextRule.policyIds)
Optional list of signers for multi-signer authorization. When empty (default), uses single-signer auth with the connected passkey. When non-empty, coordinates signatures from all listed signers.
Optional submission method override. When null (default), uses the configured submission method (relayer if available, RPC otherwise).
Throws
if no wallet is connected
if simulation, signing, or submission fails
if biometric authentication fails
Example:
// Fetch the parsed context rule to get policy IDs
val rules = kit.contextRuleManager.listContextRules()
val rule = rules.first { it.id == 0u }
val policyIdToRemove = rule.policyIds.first()
val result = policyManager.removePolicy(
contextRuleId = 0u,
policyId = policyIdToRemove
)
if (result.success) {
println("Policy removed: ${result.hash ?: ""}")
} else {
println("Failed to remove policy: ${result.error ?: ""}")
}Removes a policy from a context rule by matching the policy contract address.
Convenience overload that resolves the on-chain policy ID internally. Fetches the specified context rule (single RPC call), finds the policy matching the given address, and delegates to the ID-based removePolicy.
Return
TransactionResult indicating success or failure
Parameters
The context rule ID to remove the policy from
The policy contract address (C-address) to remove
Optional list of signers for multi-signer authorization. When empty (default), uses single-signer auth with the connected passkey. When non-empty, coordinates signatures from all listed signers.
Optional submission method override. When null (default), uses the configured submission method (relayer if available, RPC otherwise).
Throws
if no wallet is connected
if the policy address is not found on the context rule
if simulation, signing, or submission fails
if biometric authentication fails
Example:
val result = kit.policyManager.removePolicy(
contextRuleId = 1u,
policyAddress = "CPOLICY..."
)