MuxedContract

public struct MuxedContract : Equatable, Sendable

A contract with an optional 64-bit multiplexing id (CAP-0084).

A muxed contract address pairs a contract with an id the way a muxed account address pairs an account with one. Its address is the “W…” strkey when the multiplexing id is set and the “C…” strkey of the contract when it is not. The Stellar Asset Contract accepts a muxed contract address as the recipient of a transfer; it is never an authorization address.

let muxed = try MuxedContract(contractId: "CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE",
                              id: 123456)
print(muxed.address) // WA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAAAAAAAAAPCIA6IG

let parsed = try MuxedContract(address: muxed.address)
print(parsed.contractId) // CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE
print(parsed.id ?? 0)    // 123456
  • The contract id (“C…”).

    Declaration

    Swift

    public let contractId: String
  • id

    The multiplexing id, nil for a plain contract address.

    Declaration

    Swift

    public let id: UInt64?
  • The muxed contract address (“W…”) when id is set, otherwise contractId.

    Declaration

    Swift

    public let address: String
  • Creates a muxed contract from a contract id and a multiplexing id.

    Throws

    StellarSDKError.invalidArgument naming the value if contractId is not a valid contract id, or only its kind if it starts with “S” or “s”

    Declaration

    Swift

    public init(contractId: String, id: UInt64) throws

    Parameters

    contractId

    the contract id (“C…”)

    id

    the multiplexing id

  • Creates a muxed contract from a contract address (“C…”), which leaves id nil, or from a muxed contract address (“W…”).

    Throws

    StellarSDKError.invalidArgument naming the value if address is neither, or only its kind if it starts with “S” or “s”

    Declaration

    Swift

    public init(address: String) throws
  • Creates a muxed contract from the contract arm of an XDR address, which leaves id nil, or from its muxed contract arm.

    Throws

    StellarSDKError.invalidArgument naming the arm for any other arm

    Declaration

    Swift

    public init(scAddress: SCAddressXDR) throws
  • Converts this muxed contract to its XDR address: the muxed contract arm when id is set, the contract arm when it is not.

    Declaration

    Swift

    public func toSCAddress() -> SCAddressXDR