attachDelegates

Constructs a WITH_DELEGATES authorization entry from an ADDRESS or ADDRESS_V2 entry, attaching a sorted, validated delegate tree.

The delegates list (and every nested delegate array) is sorted ascending by the XDR-encoded bytes of each delegate's SCAddressXdr. This order is required by the host; strkey ordering differs (G... < C... as strings, but ACCOUNT < CONTRACT by XDR discriminant, so account addresses sort before contract addresses under XDR byte comparison).

Within any single delegate array, duplicate addresses are rejected. The same address may appear at different nesting levels.

The top-level signature in the returned entry is void; call authorizeEntry (with AuthOptions.forAddress = null to sign the top-level, or set to a delegate's address to sign that node) to add signatures.

After attaching delegates the initial simulation does not include the delegate authorization. Re-simulate in enforcing mode to capture the updated resource usage before submitting (see CAP-0071-01 Appendix).

Return

A new entry with AddressWithDelegates credentials and void top-level signature

Parameters

entry

Source entry with ADDRESS or ADDRESS_V2 credentials. Throws if the entry already carries AddressWithDelegates credentials.

validUntilLedgerSeq

Expiration ledger sequence for the top-level credentials

delegates

Delegate descriptors; sorted and duplicate-checked on construction

Throws

if the entry already has AddressWithDelegates credentials, if the source entry has Void credentials, if any address is invalid or muxed, or if duplicates exist within a single delegate array