Expand description
§xmtp
Safe, ergonomic Rust SDK for the XMTP messaging protocol.
Wraps the xmtp-sys FFI bindings with idiomatic Rust types, providing a high-level Client → Conversation → Message API for E2E encrypted DMs, groups, content types, identity management, ENS resolution, and real-time streaming.
§Quick Start
ⓘ
use xmtp::{Client, Env, AlloySigner};
// Create a client and register identity.
let signer = AlloySigner::random()?;
let client = Client::builder()
.env(Env::Dev)
.db_path("./alice.db3")
.build(&signer)?;
// Send a DM.
let conv = client.dm(&"0xBob...".into())?;
conv.send_text("hello from Rust")?;
// Stream messages in real time.
let _handle = xmtp::stream::stream_all_messages(
&client, None, &[], |msg_id, conv_id| {
println!("new message {msg_id} in {conv_id}");
},
)?;§Feature Flags
| Feature | Default | Description |
|---|---|---|
content | ✅ | Content type codecs (text, reactions, replies, attachments, read receipts) |
alloy | Local private key signer via alloy-signer-local | |
ledger | Ledger hardware wallet signer via alloy-signer-ledger | |
ens | ENS name resolution via alloy-ens + alloy-provider |
§License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.
Re-exports§
pub use client::Client;pub use client::ClientBuilder;pub use conversation::Conversation;pub use conversation::GroupMember;pub use conversation::Message;pub use error::Error;pub use error::Result;pub use resolve::Recipient;pub use resolve::Resolver;pub use stream::ConsentUpdate;pub use stream::MessageEvent;pub use stream::PreferenceUpdate;pub use stream::Subscription;pub use types::AccountIdentifier;pub use types::ApiStats;pub use types::ConsentEntityType;pub use types::ConsentState;pub use types::ConversationDebugInfo;pub use types::ConversationMetadata;pub use types::ConversationOrderBy;pub use types::ConversationType;pub use types::CreateDmOptions;pub use types::CreateGroupOptions;pub use types::Cursor;pub use types::DeliveryStatus;pub use types::DisappearingSettings;pub use types::Env;pub use types::GroupPermissionsPreset;pub use types::HmacKey;pub use types::HmacKeyEntry;pub use types::IdentifierKind;pub use types::IdentityStats;pub use types::InboxState;pub use types::KeyPackageStatus;pub use types::LastReadTime;pub use types::ListConversationsOptions;pub use types::ListMessagesOptions;pub use types::MembershipState;pub use types::MessageKind;pub use types::MetadataField;pub use types::PermissionLevel;pub use types::PermissionPolicy;pub use types::PermissionPolicySet;pub use types::PermissionUpdateType;pub use types::Permissions;pub use types::SendOptions;pub use types::Signer;pub use types::SortDirection;pub use types::SyncResult;pub use client::generate_inbox_id;pub use client::get_inbox_id_for_identifier;pub use client::init_logger;pub use client::libxmtp_version;pub use client::verify_signed_with_public_key;
Modules§
- client
- XMTP client — the primary entry point for the SDK.
- content
- Content type encoding, decoding, and typed send helpers.
- conversation
- Conversation operations: send, messages, members, metadata, consent, disappearing messages, admin management, permissions, debug info, and HMAC keys.
- error
- Unified error types for the XMTP SDK.
- resolve
- Unified recipient resolution for XMTP messaging.
- stream
- Channel-based streaming for real-time event subscriptions.
- types
- SDK types: enumerations, option structs, data structs, and signer trait.
Structs§
- Alloy
Signer - A local Ethereum private-key signer powered by
alloy-signer-local. - EnsResolver
- ENS name resolver connecting to an Ethereum JSON-RPC endpoint.
- Ledger
Signer - A Ledger hardware wallet signer powered by
alloy-signer-ledger.