sign Auth Entries
Signs authorization entries in the transaction.
This method is used for multi-authorization workflows where the contract invocation requires authorization from specific accounts (other than the transaction invoker).
Use Cases
Atomic Swaps: Alice and Bob both need to authorize their token transfers
Multi-Signature Operations: Multiple parties must approve a contract action
Remote Signing: One party signs locally, another signs on a remote server
Parameters
authEntriesSigner: The KeyPair to sign with. Can be public-key-only if using delegate.
validUntilLedgerSequence: Optional expiration ledger. Defaults to current + 100 (~8.3 minutes).
authorizeEntryDelegate: Optional function for custom/remote signing logic.
Basic Usage (Local Signing)
val tx = swapClient.invoke<Unit>(
functionName = "swap",
parameters = swapParams,
source = invokerAccount,
signer = invokerKeyPair
)
// Sign auth entries for Alice (has private key)
tx.signAuthEntries(aliceKeyPair)
// Sign auth entries for Bob (has private key)
tx.signAuthEntries(bobKeyPair)
// Submit the fully-signed transaction
val result = tx.signAndSubmit(invokerKeyPair)Remote Signing (Delegate Pattern)
// Bob's signing happens on a remote server
val bobPublicOnly = KeyPair.fromAccountId(bobId)
tx.signAuthEntries(
authEntriesSigner = bobPublicOnly,
authorizeEntryDelegate = { entry, network ->
// Send to remote server
val entryXdr = entry.toXdrBase64()
val signedXdr = httpClient.post("/sign", entryXdr)
// Return signed entry
SorobanAuthorizationEntryXdr.fromXdrBase64(signedXdr)
}
)Custom Expiration
// Get current ledger
val latestLedger = server.getLatestLedger()
// Set expiration to 1 hour from now (~720 ledgers)
tx.signAuthEntries(
authEntriesSigner = aliceKeyPair,
validUntilLedgerSequence = latestLedger.sequence + 720
)How It Works
The method finds all auth entries that match the signer's address
For each matching entry:
Sets the expiration ledger
Signs the entry using Auth.authorizeEntry() or the delegate
Updates the signature in the entry
Rebuilds the transaction with the updated auth entries
Return
This AssembledTransaction for chaining
Parameters
The KeyPair to sign auth entries with (must match address in entry)
Ledger sequence until which signatures are valid (null = current + 100)
Optional function for custom signing logic (enables remote signing)
Throws
if not yet simulated
if no entries need signing or wrong signer
if signer missing private key (when delegate not provided)