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 -
The multiplexing id, nil for a plain contract address.
Declaration
Swift
public let id: UInt64? -
The muxed contract address (“W…”) when
idis set, otherwisecontractId.Declaration
Swift
public let address: String -
Creates a muxed contract from a contract id and a multiplexing id.
Throws
StellarSDKError.invalidArgument naming the value ifcontractIdis not a valid contract id, or only its kind if it starts with “S” or “s”Declaration
Swift
public init(contractId: String, id: UInt64) throwsParameters
contractIdthe contract id (“C…”)
idthe multiplexing id
-
Creates a muxed contract from the contract arm of an XDR address, which leaves
idnil, or from its muxed contract arm.Throws
StellarSDKError.invalidArgument naming the arm for any other armDeclaration
Swift
public init(scAddress: SCAddressXDR) throws -
Converts this muxed contract to its XDR address: the muxed contract arm when
idis set, the contract arm when it is not.Declaration
Swift
public func toSCAddress() -> SCAddressXDR
View on GitHub
Install in Dash