addDelegated

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

Adds a delegated signer to a context rule.

Creates a delegated signer that uses built-in Soroban require_auth verification and adds it to the specified context rule. The address can be either a Stellar account (G-address) or a smart contract (C-address).

Delegated signers authorize transactions using the native Soroban authorization mechanism, which calls require_auth_for_args() on the signer's address.

The transaction requires authorization from an existing signer on the specified context rule.

Contract call: smart_account.add_signer(context_rule_id, signer) — returns a u32 signer ID. The assigned ID is available via ParsedContextRule.signerIds after fetching the context rule.

Return

TransactionResult indicating success or failure

Parameters

contextRuleId

The context rule ID to add the signer to (e.g., 0 for Default)

address

The Stellar address (G-address for accounts, C-address for contracts)

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 validation fails or transaction fails

Example:

// Add an account signer (single-signer)
val result = signerManager.addDelegated(
contextRuleId = 0u,
address = "GA7QYNF7SOWQ..."
)

// Add a contract signer (multi-signer)
val contractResult = signerManager.addDelegated(
contextRuleId = 1u,
address = "CBCD1234...",
selectedSigners = listOf(
SelectedSigner.Passkey(credentialId = cred1, credentialIdBytes = cred1Bytes, keyData = key1),
SelectedSigner.Wallet("GA7Q...")
)
)