removePolicy

suspend fun removePolicy(contextRuleId: UInt, policyId: UInt, selectedSigners: List<SelectedSigner> = emptyList(), forceMethod: SubmissionMethod? = null): TransactionResult

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:

  1. Validates that a wallet is connected

  2. Builds contract invocation for remove_policy

  3. 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

contextRuleId

The context rule ID to remove the policy from (0 for Default rule)

policyId

The on-chain policy ID assigned by the contract (available from ParsedContextRule.policyIds)

selectedSigners

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.

forceMethod

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 ?: ""}")
}

suspend fun removePolicy(contextRuleId: UInt, policyAddress: String, selectedSigners: List<SelectedSigner> = emptyList(), forceMethod: SubmissionMethod? = null): TransactionResult

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

contextRuleId

The context rule ID to remove the policy from

policyAddress

The policy contract address (C-address) to remove

selectedSigners

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.

forceMethod

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..."
)