pub struct Client { /* private fields */ }Expand description
The Client.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(sender: RpcChannel) -> Self
pub fn new(sender: RpcChannel) -> Self
Creates a new Client.
Sourcepub fn slot_subscribe(&self) -> RpcResult<TypedSubscriptionStream<SlotInfo>>
pub fn slot_subscribe(&self) -> RpcResult<TypedSubscriptionStream<SlotInfo>>
Subscribe to slot notifications.
This method allows clients to subscribe to updates for a specific slot. The subscriber will receive notifications whenever the slot changes.
§Parameters
meta: WebSocket metadata containing RPC context and connection information.subscriber: The subscription sink for sending slot update notifications to the client.
§Returns
This method does not return a value directly. Instead, it establishes a continuous WebSocket
subscription that will send SlotInfo notifications to the subscriber whenever
the slot changes.
§Example WebSocket Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "slotSubscribe",
"params": [
{
"commitment": "finalized"
}
]
}§Example WebSocket Response (Subscription Confirmation)
{
"jsonrpc": "2.0",
"result": 5207624,
"id": 1
}§Example WebSocket Notification
{
"jsonrpc": "2.0",
"method": "slotNotification",
"params": {
"result": {
"slot": 5207624
},
"subscription": 5207624
}
}§Notes
- The subscription remains active until explicitly unsubscribed or the connection is closed.
- Slot notifications are sent whenever the slot changes.
- The subscription automatically terminates when the slot changes.
- Each subscription runs in its own async task for optimal performance.
§See Also
slotUnsubscribe: Remove an active slot subscription
Sourcepub fn account_subscribe(
&self,
pubkey_str: String,
config: Option<RpcAccountSubscribeConfig>,
) -> RpcResult<TypedSubscriptionStream<RpcResponse<UiAccount>>>
pub fn account_subscribe( &self, pubkey_str: String, config: Option<RpcAccountSubscribeConfig>, ) -> RpcResult<TypedSubscriptionStream<RpcResponse<UiAccount>>>
Subscribe to account change notifications via WebSocket.
This method allows clients to subscribe to updates for a specific account. The subscriber will receive notifications whenever the account’s data, lamports balance, ownership, or other properties change.
§Parameters
meta: WebSocket metadata containing RPC context and connection information.subscriber: The subscription sink for sending account update notifications to the client.pubkey_str: The account public key to monitor, as a base-58 encoded string.config: Optional configuration specifying commitment level and encoding format for account data.
§Returns
This method does not return a value directly. Instead, it establishes a continuous WebSocket
subscription that will send RpcResponse<UiAccount> notifications to the subscriber whenever
the account state changes.
§Example WebSocket Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "accountSubscribe",
"params": [
"CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12",
{
"commitment": "finalized",
"encoding": "base64"
}
]
}§Example WebSocket Response (Subscription Confirmation)
{
"jsonrpc": "2.0",
"result": 23784,
"id": 1
}§Example WebSocket Notification
{
"jsonrpc": "2.0",
"method": "accountNotification",
"params": {
"result": {
"context": {
"slot": 5208469
},
"value": {
"data": ["base64EncodedAccountData", "base64"],
"executable": false,
"lamports": 33594,
"owner": "11111111111111111111111111111112",
"rentEpoch": 636
}
},
"subscription": 23784
}
}§Notes
- The subscription remains active until explicitly unsubscribed or the connection is closed.
- Account notifications are sent whenever any aspect of the account changes.
- The encoding format specified in the config determines how account data is serialized.
- Invalid public key formats will cause the subscription to be rejected with an error.
- Each subscription runs in its own async task to ensure optimal performance.
§See Also
accountUnsubscribe: Remove an active account subscriptiongetAccountInfo: Get current account information
Sourcepub fn signature_subscribe(
&self,
signature_str: String,
config: Option<RpcSignatureSubscribeConfig>,
) -> RpcResult<TypedSubscriptionStream<RpcResponse<RpcSignatureResult>>>
pub fn signature_subscribe( &self, signature_str: String, config: Option<RpcSignatureSubscribeConfig>, ) -> RpcResult<TypedSubscriptionStream<RpcResponse<RpcSignatureResult>>>
Subscribe to signature status notifications via WebSocket.
This method allows clients to subscribe to status updates for a specific transaction signature. The subscriber will receive notifications when the transaction reaches the desired confirmation level or when it’s initially received by the network (if configured).
§Parameters
meta: WebSocket metadata containing RPC context and connection information.subscriber: The subscription sink for sending signature status notifications to the client.signature_str: The transaction signature to monitor, as a base-58 encoded string.config: Optional configuration specifying commitment level and notification preferences.
§Returns
This method does not return a value directly. Instead, it establishes a WebSocket subscription
that will send RpcResponse<RpcSignatureResult> notifications to the subscriber when the
transaction status changes.
§Example WebSocket Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "signatureSubscribe",
"params": [
"2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb",
{
"commitment": "finalized",
"enableReceivedNotification": false
}
]
}§Example WebSocket Response (Subscription Confirmation)
{
"jsonrpc": "2.0",
"result": 0,
"id": 1
}§Example WebSocket Notification
{
"jsonrpc": "2.0",
"method": "signatureNotification",
"params": {
"result": {
"context": {
"slot": 5207624
},
"value": {
"err": null
}
},
"subscription": 0
}
}§Notes
- If the transaction already exists with the desired confirmation status, the subscriber will be notified immediately and the subscription will complete.
- The subscription automatically terminates after sending the first matching notification.
- Invalid signature formats will cause the subscription to be rejected with an error.
- Each subscription runs in its own async task for optimal performance.
§See Also
signatureUnsubscribe: Remove an active signature subscriptiongetSignatureStatuses: Get current status of multiple signatures
Sourcepub fn logs_subscribe(
&self,
mentions: Option<RpcTransactionLogsFilter>,
commitment: Option<CommitmentLevel>,
) -> RpcResult<TypedSubscriptionStream<RpcResponse<RpcLogsResponse>>>
pub fn logs_subscribe( &self, mentions: Option<RpcTransactionLogsFilter>, commitment: Option<CommitmentLevel>, ) -> RpcResult<TypedSubscriptionStream<RpcResponse<RpcLogsResponse>>>
Subscribe to logs notifications.
This method allows clients to subscribe to transaction log messages emitted during transaction execution. It supports filtering by signature, account mentions, or all transactions.
§Parameters
meta: WebSocket metadata containing RPC context and connection information.subscriber: The subscription sink for sending log notifications to the client.mentions: Optional filter for the subscription: can be a specific signature, account, or"all".commitment: Optional commitment level for filtering logs by block finality.
§Returns
This method establishes a continuous WebSocket subscription that streams
RpcLogsResponse notifications as new transactions are processed.
§Example WebSocket Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "logsSubscribe",
"params": [
{
"mentions": ["11111111111111111111111111111111"]
},
{
"commitment": "finalized"
}
]
}§Example WebSocket Response (Subscription Confirmation)
{
"jsonrpc": "2.0",
"result": 42,
"id": 1
}§Example WebSocket Notification
{
"jsonrpc": "2.0",
"method": "logsNotification",
"params": {
"result": {
"signature": "3s6n...",
"err": null,
"logs": ["Program 111111... invoke [1]", "Program 111111... success"]
},
"subscription": 42
}
}§Notes
- The subscription remains active until explicitly unsubscribed or the connection is closed.
- Each log subscription runs independently and supports filtering.
- Log messages may be truncated depending on cluster configuration.
§See Also
logsUnsubscribe: Remove an active logs subscription.
Trait Implementations§
Source§impl From<RpcChannel> for Client
impl From<RpcChannel> for Client
Source§fn from(channel: RpcChannel) -> Self
fn from(channel: RpcChannel) -> Self
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more