Client
public final class Client : Sendable
Client is the entrypoint into the XMTP SDK.
A client is created by calling create(account:options:)
with a SigningKey
that can create signatures on your behalf. The client will request a signature in two cases:
- To sign the newly generated key bundle. This happens only the very first time when a key bundle is not found in storage.
- To sign a random salt used to encrypt the key bundle in storage. This happens every time the client is started, including the very first time).
Important
The client connects to the XMTP dev
environment by default. Use ClientOptions
to change this and other parameters of the network connection.
-
The wallet address of the
SigningKey
used to create this Client.Declaration
Swift
public let address: String
-
Access
Conversations
for this Client.Declaration
Swift
public lazy var conversations: Conversations { get set }
-
The XMTP environment which specifies which network this Client is connected to.
Declaration
Swift
public var environment: XMTPEnvironment { get }
-
Undocumented
Declaration
Swift
public func register(codec: any ContentCodec)
-
create(account:
Asynchronousoptions: ) Creates a client.
Declaration
Swift
public static func create(account: SigningKey, options: ClientOptions? = nil) async throws -> Client
-
from(bundle:
Asynchronousoptions: ) Undocumented
Declaration
Swift
public static func from(bundle: PrivateKeyBundle, options: ClientOptions? = nil) async throws -> Client
-
from(v1Bundle:
Asynchronousoptions: ) Create a Client from saved v1 key bundle.
Declaration
Swift
public static func from(v1Bundle: PrivateKeyBundleV1, options: ClientOptions? = nil) async throws -> Client
-
Undocumented
Declaration
Swift
public var privateKeyBundle: PrivateKeyBundle { get }
-
Undocumented
Declaration
Swift
public var publicKeyBundle: SignedPublicKeyBundle { get }
-
Undocumented
Declaration
Swift
public var v1keys: PrivateKeyBundleV1 { get }
-
Undocumented
Declaration
Swift
public var keys: PrivateKeyBundleV2 { get }
-
canMessage(_:
Asynchronous) Undocumented
Declaration
Swift
public func canMessage(_ peerAddress: String) async throws -> Bool
-
canMessage(_:
Asynchronousoptions: ) Undocumented
Declaration
Swift
public static func canMessage(_ peerAddress: String, options: ClientOptions? = nil) async throws -> Bool
-
Undocumented
Declaration
Swift
public func importConversation(from conversationData: Data) throws -> Conversation?
-
query(topic:
Asynchronouspagination: ) Undocumented
Declaration
Swift
public func query(topic: Topic, pagination: Pagination? = nil) async throws -> QueryResponse
-
batchQuery(request:
Asynchronous) Undocumented
Declaration
Swift
public func batchQuery(request: BatchQueryRequest) async throws -> BatchQueryResponse
-
publish(envelopes:
Asynchronous) Undocumented
Declaration
Swift
@discardableResult public func publish(envelopes: [Envelope]) async throws -> PublishResponse
-
Undocumented
Declaration
Swift
public func subscribe(topics: [String]) -> AsyncThrowingStream<Envelope, Error>