pub struct RpcClient { /* private fields */ }
Expand description
A client of a remote Solana node.
RpcClient
communicates with a Solana node over JSON-RPC, with the
Solana JSON-RPC protocol. It is the primary Rust interface for
querying and transacting with the network from external programs.
This type builds on the underlying RPC protocol, adding extra features such
as timeout handling, retries, and waiting on transaction commitment levels.
Some methods simply pass through to the underlying RPC protocol. Not all RPC
methods are encapsulated by this type, but RpcClient
does expose a generic
send
method for making any RpcRequest
.
The documentation for most RpcClient
methods contains an “RPC Reference”
section that links to the documentation for the underlying JSON-RPC method.
The documentation for RpcClient
does not reproduce the documentation for
the underlying JSON-RPC methods. Thus reading both is necessary for complete
understanding.
RpcClient
s generally communicate over HTTP on port 8899, a typical server
URL being “http://localhost:8899”.
Methods that query information from recent slots, including those that
confirm transactions, decide the most recent slot to query based on a
commitment level, which determines how committed or finalized a slot
must be to be considered for the query. Unless specified otherwise, the
commitment level is Finalized
, meaning the slot is definitely
permanently committed. The default commitment level can be configured by
creating RpcClient
with an explicit CommitmentConfig
, and that default
configured commitment level can be overridden by calling the various
_with_commitment
methods, like
RpcClient::confirm_transaction_with_commitment
. In some cases the
configured commitment level is ignored and Finalized
is used instead, as
in RpcClient::get_blocks
, where it would be invalid to use the
Processed
commitment level. These exceptions are noted in the method
documentation.
§Errors
Methods on RpcClient
return
client_error::Result
, and many of them
return the RpcResult
typedef, which
contains Response<T>
on Ok
. Both
client_error::Result
and RpcResult
contain ClientError
on error. In
the case of RpcResult
, the actual return value is in the
value
field, with RPC contextual
information in the context
field, so it is common for the value to be accessed with ?.value
, as in
let signature = rpc_client.send_transaction(&tx)?;
let statuses = rpc_client.get_signature_statuses(&[signature])?.value;
Requests may timeout, in which case they return a ClientError
where the
ClientErrorKind
is ClientErrorKind::Reqwest
, and where the interior
reqwest::Error
s
is_timeout
method
returns true
. The default timeout is 30 seconds, and may be changed by
calling an appropriate constructor with a timeout
parameter.
Implementations§
source§impl RpcClient
impl RpcClient
sourcepub fn new_sender<T: RpcSender + Send + Sync + 'static>(
sender: T,
config: RpcClientConfig,
) -> Self
pub fn new_sender<T: RpcSender + Send + Sync + 'static>( sender: T, config: RpcClientConfig, ) -> Self
Create an RpcClient
from an RpcSender
and an RpcClientConfig
.
This is the basic constructor, allowing construction with any type of
RpcSender
. Most applications should use one of the other constructors,
such as RpcClient::new
, RpcClient::new_with_commitment
or
RpcClient::new_with_timeout
.
sourcepub fn new<U: ToString>(url: U) -> Self
pub fn new<U: ToString>(url: U) -> Self
Create an HTTP RpcClient
.
The URL is an HTTP URL, usually for port 8899, as in “http://localhost:8899”.
The client has a default timeout of 30 seconds, and a default commitment
level of Finalized
.
§Examples
let url = "http://localhost:8899".to_string();
let client = RpcClient::new(url);
sourcepub fn new_with_commitment<U: ToString>(
url: U,
commitment_config: CommitmentConfig,
) -> Self
pub fn new_with_commitment<U: ToString>( url: U, commitment_config: CommitmentConfig, ) -> Self
Create an HTTP RpcClient
with specified commitment level.
The URL is an HTTP URL, usually for port 8899, as in “http://localhost:8899”.
The client has a default timeout of 30 seconds, and a user-specified
CommitmentLevel
via CommitmentConfig
.
§Examples
let url = "http://localhost:8899".to_string();
let commitment_config = CommitmentConfig::processed();
let client = RpcClient::new_with_commitment(url, commitment_config);
sourcepub fn new_with_timeout<U: ToString>(url: U, timeout: Duration) -> Self
pub fn new_with_timeout<U: ToString>(url: U, timeout: Duration) -> Self
Create an HTTP RpcClient
with specified timeout.
The URL is an HTTP URL, usually for port 8899, as in “http://localhost:8899”.
The client has and a default commitment level of
Finalized
.
§Examples
let url = "http://localhost::8899".to_string();
let timeout = Duration::from_secs(1);
let client = RpcClient::new_with_timeout(url, timeout);
sourcepub fn new_with_timeout_and_commitment<U: ToString>(
url: U,
timeout: Duration,
commitment_config: CommitmentConfig,
) -> Self
pub fn new_with_timeout_and_commitment<U: ToString>( url: U, timeout: Duration, commitment_config: CommitmentConfig, ) -> Self
Create an HTTP RpcClient
with specified timeout and commitment level.
The URL is an HTTP URL, usually for port 8899, as in “http://localhost:8899”.
§Examples
let url = "http://localhost::8899".to_string();
let timeout = Duration::from_secs(1);
let commitment_config = CommitmentConfig::processed();
let client = RpcClient::new_with_timeout_and_commitment(
url,
timeout,
commitment_config,
);
sourcepub fn new_with_timeouts_and_commitment<U: ToString>(
url: U,
timeout: Duration,
commitment_config: CommitmentConfig,
confirm_transaction_initial_timeout: Duration,
) -> Self
pub fn new_with_timeouts_and_commitment<U: ToString>( url: U, timeout: Duration, commitment_config: CommitmentConfig, confirm_transaction_initial_timeout: Duration, ) -> Self
Create an HTTP RpcClient
with specified timeout and commitment level.
The URL is an HTTP URL, usually for port 8899, as in “http://localhost:8899”.
The confirm_transaction_initial_timeout
argument specifies the amount of
time to allow for the server to initially process a transaction, when
confirming a transaction via one of the _with_spinner
methods, like
RpcClient::send_and_confirm_transaction_with_spinner
. In
other words, setting confirm_transaction_initial_timeout
to > 0 allows
RpcClient
to wait for confirmation of a transaction that the server
has not “seen” yet.
§Examples
let url = "http://localhost::8899".to_string();
let timeout = Duration::from_secs(1);
let commitment_config = CommitmentConfig::processed();
let confirm_transaction_initial_timeout = Duration::from_secs(10);
let client = RpcClient::new_with_timeouts_and_commitment(
url,
timeout,
commitment_config,
confirm_transaction_initial_timeout,
);
sourcepub fn new_mock<U: ToString>(url: U) -> Self
pub fn new_mock<U: ToString>(url: U) -> Self
Create a mock RpcClient
.
A mock RpcClient
contains an implementation of RpcSender
that does
not use the network, and instead returns synthetic responses, for use in
tests.
It is primarily for internal use, with limited customizability, and
behaviors determined by internal Solana test cases. New users should
consider implementing RpcSender
themselves and constructing
RpcClient
with RpcClient::new_sender
to get mock behavior.
Unless directed otherwise, a mock RpcClient
will generally return a
reasonable default response to any request, at least for RpcRequest
values for which responses have been implemented.
This mock can be customized by changing the url
argument, which is not
actually a URL, but a simple string directive that changes the mock
behavior in specific scenarios:
-
It is customary to set the
url
to “succeeds” for mocks that should return successfully, though this value is not actually interpreted. -
If
url
is “fails” then any call tosend
will returnOk(Value::Null)
. -
Other possible values of
url
are specific to differentRpcRequest
values. Read the implementation of (non-public)MockSender
for details.
The RpcClient::new_mock_with_mocks
function offers further
customization options.
§Examples
// Create an `RpcClient` that always succeeds
let url = "succeeds".to_string();
let successful_client = RpcClient::new_mock(url);
// Create an `RpcClient` that always fails
let url = "fails".to_string();
let successful_client = RpcClient::new_mock(url);
sourcepub fn new_mock_with_mocks<U: ToString>(url: U, mocks: Mocks) -> Self
pub fn new_mock_with_mocks<U: ToString>(url: U, mocks: Mocks) -> Self
Create a mock RpcClient
.
A mock RpcClient
contains an implementation of RpcSender
that does
not use the network, and instead returns synthetic responses, for use in
tests.
It is primarily for internal use, with limited customizability, and
behaviors determined by internal Solana test cases. New users should
consider implementing RpcSender
themselves and constructing
RpcClient
with RpcClient::new_sender
to get mock behavior.
Unless directed otherwise, a mock RpcClient
will generally return a
reasonable default response to any request, at least for RpcRequest
values for which responses have been implemented.
This mock can be customized in two ways:
-
By changing the
url
argument, which is not actually a URL, but a simple string directive that changes the mock behavior in specific scenarios.It is customary to set the
url
to “succeeds” for mocks that should return successfully, though this value is not actually interpreted.If
url
is “fails” then any call tosend
will returnOk(Value::Null)
.Other possible values of
url
are specific to differentRpcRequest
values. Read the implementation ofMockSender
(which is non-public) for details. -
Custom responses can be configured by providing
Mocks
. This type is aHashMap
fromRpcRequest
to a JSONValue
response, Any entries in this map override the default behavior for the given request.
The RpcClient::new_mock_with_mocks
function offers further
customization options.
§Examples
// Create a mock with a custom response to the `GetBalance` request
let account_balance = 50;
let account_balance_response = json!(Response {
context: RpcResponseContext { slot: 1, api_version: None },
value: json!(account_balance),
});
let mut mocks = HashMap::new();
mocks.insert(RpcRequest::GetBalance, account_balance_response);
let url = "succeeds".to_string();
let client = RpcClient::new_mock_with_mocks(url, mocks);
sourcepub fn new_socket(addr: SocketAddr) -> Self
pub fn new_socket(addr: SocketAddr) -> Self
Create an HTTP RpcClient
from a SocketAddr
.
The client has a default timeout of 30 seconds, and a default commitment
level of Finalized
.
§Examples
let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899));
let client = RpcClient::new_socket(addr);
sourcepub fn new_socket_with_commitment(
addr: SocketAddr,
commitment_config: CommitmentConfig,
) -> Self
pub fn new_socket_with_commitment( addr: SocketAddr, commitment_config: CommitmentConfig, ) -> Self
Create an HTTP RpcClient
from a SocketAddr
with specified commitment level.
The client has a default timeout of 30 seconds, and a user-specified
CommitmentLevel
via CommitmentConfig
.
§Examples
let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899));
let commitment_config = CommitmentConfig::processed();
let client = RpcClient::new_socket_with_commitment(
addr,
commitment_config
);
sourcepub fn new_socket_with_timeout(addr: SocketAddr, timeout: Duration) -> Self
pub fn new_socket_with_timeout(addr: SocketAddr, timeout: Duration) -> Self
Create an HTTP RpcClient
from a SocketAddr
with specified timeout.
The client has a default commitment level of Finalized
.
§Examples
let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899));
let timeout = Duration::from_secs(1);
let client = RpcClient::new_socket_with_timeout(addr, timeout);
sourcepub fn commitment(&self) -> CommitmentConfig
pub fn commitment(&self) -> CommitmentConfig
Get the configured default commitment level.
The commitment config may be specified during construction, and
determines how thoroughly committed a transaction must be when waiting
for its confirmation or otherwise checking for confirmation. If not
specified, the default commitment level is
Finalized
.
The default commitment level is overridden when calling methods that
explicitly provide a CommitmentConfig
, like
RpcClient::confirm_transaction_with_commitment
.
sourcepub fn send_and_confirm_transaction(
&self,
transaction: &impl SerializableTransaction,
) -> ClientResult<Signature>
pub fn send_and_confirm_transaction( &self, transaction: &impl SerializableTransaction, ) -> ClientResult<Signature>
Submit a transaction and wait for confirmation.
Once this function returns successfully, the given transaction is guaranteed to be processed with the configured commitment level.
After sending the transaction, this method polls in a loop for the status of the transaction until it has ben confirmed.
§Errors
If the transaction is not signed then an error with kind RpcError
is
returned, containing an RpcResponseError
with code
set to
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE
.
If the preflight transaction simulation fails then an error with kind
RpcError
is returned, containing an RpcResponseError
with code
set to JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE
.
If the receiving node is unhealthy, e.g. it is not fully synced to
the cluster, then an error with kind RpcError
is returned,
containing an RpcResponseError
with code
set to
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY
.
§RPC Reference
This method is built on the sendTransaction
RPC method, and the
getLatestBlockhash
RPC method.
§Examples
let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash);
let signature = rpc_client.send_and_confirm_transaction(&tx)?;
pub fn send_and_confirm_transaction_with_spinner( &self, transaction: &impl SerializableTransaction, ) -> ClientResult<Signature>
pub fn send_and_confirm_transaction_with_spinner_and_commitment( &self, transaction: &impl SerializableTransaction, commitment: CommitmentConfig, ) -> ClientResult<Signature>
pub fn send_and_confirm_transaction_with_spinner_and_config( &self, transaction: &impl SerializableTransaction, commitment: CommitmentConfig, config: RpcSendTransactionConfig, ) -> ClientResult<Signature>
sourcepub fn send_transaction(
&self,
transaction: &impl SerializableTransaction,
) -> ClientResult<Signature>
pub fn send_transaction( &self, transaction: &impl SerializableTransaction, ) -> ClientResult<Signature>
Submits a signed transaction to the network.
Before a transaction is processed, the receiving node runs a “preflight
check” which verifies signatures, checks that the node is healthy,
and simulates the transaction. If the preflight check fails then an
error is returned immediately. Preflight checks can be disabled by
calling send_transaction_with_config
and setting the
skip_preflight
field of RpcSendTransactionConfig
to true
.
This method does not wait for the transaction to be processed or
confirmed before returning successfully. To wait for the transaction to
be processed or confirmed, use the send_and_confirm_transaction
method.
§Errors
If the transaction is not signed then an error with kind RpcError
is
returned, containing an RpcResponseError
with code
set to
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE
.
If the preflight transaction simulation fails then an error with kind
RpcError
is returned, containing an RpcResponseError
with code
set to JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE
.
If the receiving node is unhealthy, e.g. it is not fully synced to
the cluster, then an error with kind RpcError
is returned,
containing an RpcResponseError
with code
set to
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY
.
§RPC Reference
This method is built on the sendTransaction
RPC method.
§Examples
// Transfer lamports from Alice to Bob
let latest_blockhash = rpc_client.get_latest_blockhash()?;
let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash);
let signature = rpc_client.send_transaction(&tx)?;
sourcepub fn send_transaction_with_config(
&self,
transaction: &impl SerializableTransaction,
config: RpcSendTransactionConfig,
) -> ClientResult<Signature>
pub fn send_transaction_with_config( &self, transaction: &impl SerializableTransaction, config: RpcSendTransactionConfig, ) -> ClientResult<Signature>
Submits a signed transaction to the network.
Before a transaction is processed, the receiving node runs a “preflight
check” which verifies signatures, checks that the node is healthy, and
simulates the transaction. If the preflight check fails then an error is
returned immediately. Preflight checks can be disabled by setting the
skip_preflight
field of RpcSendTransactionConfig
to true
.
This method does not wait for the transaction to be processed or
confirmed before returning successfully. To wait for the transaction to
be processed or confirmed, use the send_and_confirm_transaction
method.
§Errors
If preflight checks are enabled, if the transaction is not signed
then an error with kind RpcError
is returned, containing an
RpcResponseError
with code
set to
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE
.
If preflight checks are enabled, if the preflight transaction simulation
fails then an error with kind RpcError
is returned, containing an
RpcResponseError
with code
set to
JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE
.
If the receiving node is unhealthy, e.g. it is not fully synced to
the cluster, then an error with kind RpcError
is returned,
containing an RpcResponseError
with code
set to
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY
.
§RPC Reference
This method is built on the sendTransaction
RPC method.
§Examples
// Transfer lamports from Alice to Bob
let latest_blockhash = rpc_client.get_latest_blockhash()?;
let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash);
let config = RpcSendTransactionConfig {
skip_preflight: true,
.. RpcSendTransactionConfig::default()
};
let signature = rpc_client.send_transaction_with_config(
&tx,
config,
)?;
pub fn send<T>(&self, request: RpcRequest, params: Value) -> ClientResult<T>where
T: DeserializeOwned,
sourcepub fn confirm_transaction(&self, signature: &Signature) -> ClientResult<bool>
pub fn confirm_transaction(&self, signature: &Signature) -> ClientResult<bool>
Check the confirmation status of a transaction.
Returns true
if the given transaction succeeded and has been committed
with the configured commitment level, which can be retrieved with
the commitment
method.
Note that this method does not wait for a transaction to be confirmed
— it only checks whether a transaction has been confirmed. To
submit a transaction and wait for it to confirm, use
send_and_confirm_transaction
.
This method returns false
if the transaction failed, even if it has
been confirmed.
§RPC Reference
This method is built on the getSignatureStatuses
RPC method.
§Examples
// Transfer lamports from Alice to Bob and wait for confirmation
let latest_blockhash = rpc_client.get_latest_blockhash()?;
let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash);
let signature = rpc_client.send_transaction(&tx)?;
loop {
let confirmed = rpc_client.confirm_transaction(&signature)?;
if confirmed {
break;
}
}
sourcepub fn confirm_transaction_with_commitment(
&self,
signature: &Signature,
commitment_config: CommitmentConfig,
) -> RpcResult<bool>
pub fn confirm_transaction_with_commitment( &self, signature: &Signature, commitment_config: CommitmentConfig, ) -> RpcResult<bool>
Check the confirmation status of a transaction.
Returns an RpcResult
with value true
if the given transaction
succeeded and has been committed with the given commitment level.
Note that this method does not wait for a transaction to be confirmed
— it only checks whether a transaction has been confirmed. To
submit a transaction and wait for it to confirm, use
send_and_confirm_transaction
.
This method returns an RpcResult
with value false
if the
transaction failed, even if it has been confirmed.
§RPC Reference
This method is built on the getSignatureStatuses
RPC method.
§Examples
// Transfer lamports from Alice to Bob and wait for confirmation
let latest_blockhash = rpc_client.get_latest_blockhash()?;
let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash);
let signature = rpc_client.send_transaction(&tx)?;
loop {
let commitment_config = CommitmentConfig::processed();
let confirmed = rpc_client.confirm_transaction_with_commitment(&signature, commitment_config)?;
if confirmed.value {
break;
}
}
pub fn confirm_transaction_with_spinner( &self, signature: &Signature, recent_blockhash: &Hash, commitment_config: CommitmentConfig, ) -> ClientResult<()>
sourcepub fn simulate_transaction(
&self,
transaction: &impl SerializableTransaction,
) -> RpcResult<RpcSimulateTransactionResult>
pub fn simulate_transaction( &self, transaction: &impl SerializableTransaction, ) -> RpcResult<RpcSimulateTransactionResult>
Simulates sending a transaction.
If the transaction fails, then the err
field of the returned
RpcSimulateTransactionResult
will be Some
. Any logs emitted from
the transaction are returned in the logs
field.
Simulating a transaction is similar to the “preflight check” that is run by default when sending a transaction.
By default, signatures are not verified during simulation. To verify
signatures, call the simulate_transaction_with_config
method, with
the sig_verify
field of RpcSimulateTransactionConfig
set to
true
.
§RPC Reference
This method is built on the simulateTransaction
RPC method.
§Examples
// Transfer lamports from Alice to Bob
let latest_blockhash = rpc_client.get_latest_blockhash()?;
let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash);
let result = rpc_client.simulate_transaction(&tx)?;
assert!(result.value.err.is_none());
sourcepub fn simulate_transaction_with_config(
&self,
transaction: &impl SerializableTransaction,
config: RpcSimulateTransactionConfig,
) -> RpcResult<RpcSimulateTransactionResult>
pub fn simulate_transaction_with_config( &self, transaction: &impl SerializableTransaction, config: RpcSimulateTransactionConfig, ) -> RpcResult<RpcSimulateTransactionResult>
Simulates sending a transaction.
If the transaction fails, then the err
field of the returned
RpcSimulateTransactionResult
will be Some
. Any logs emitted from
the transaction are returned in the logs
field.
Simulating a transaction is similar to the “preflight check” that is run by default when sending a transaction.
By default, signatures are not verified during simulation. To verify
signatures, call the simulate_transaction_with_config
method, with
the sig_verify
field of RpcSimulateTransactionConfig
set to
true
.
This method can additionally query information about accounts by
including them in the accounts
field of the
RpcSimulateTransactionConfig
argument, in which case those results
are reported in the accounts
field of the returned
RpcSimulateTransactionResult
.
§RPC Reference
This method is built on the simulateTransaction
RPC method.
§Examples
// Transfer lamports from Alice to Bob
let latest_blockhash = rpc_client.get_latest_blockhash()?;
let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash);
let config = RpcSimulateTransactionConfig {
sig_verify: true,
.. RpcSimulateTransactionConfig::default()
};
let result = rpc_client.simulate_transaction_with_config(
&tx,
config,
)?;
assert!(result.value.err.is_none());
sourcepub fn get_highest_snapshot_slot(&self) -> ClientResult<RpcSnapshotSlotInfo>
pub fn get_highest_snapshot_slot(&self) -> ClientResult<RpcSnapshotSlotInfo>
Returns the highest slot information that the node has snapshots for.
This will find the highest full snapshot slot, and the highest incremental snapshot slot based on the full snapshot slot, if there is one.
§RPC Reference
This method corresponds directly to the getHighestSnapshotSlot
RPC method.
§Examples
let snapshot_slot_info = rpc_client.get_highest_snapshot_slot()?;
pub fn get_snapshot_slot(&self) -> ClientResult<Slot>
sourcepub fn get_signature_status(
&self,
signature: &Signature,
) -> ClientResult<Option<Result<()>>>
pub fn get_signature_status( &self, signature: &Signature, ) -> ClientResult<Option<Result<()>>>
Check if a transaction has been processed with the default commitment level.
If the transaction has been processed with the default commitment level,
then this method returns Ok
of Some
. If the transaction has not yet
been processed with the default commitment level, it returns Ok
of
None
.
If the transaction has been processed with the default commitment level,
and the transaction succeeded, this method returns Ok(Some(Ok(())))
.
If the transaction has been processed with the default commitment level,
and the transaction failed, this method returns Ok(Some(Err(_)))
,
where the interior error is type TransactionError
.
This function only searches a node’s recent history, including all
recent slots, plus up to
MAX_RECENT_BLOCKHASHES
rooted slots. To search the full transaction history use the
get_signature_status_with_commitment_and_history
method.
§RPC Reference
This method is built on the getSignatureStatuses
RPC method.
§Examples
let signature = rpc_client.send_transaction(&tx)?;
let status = rpc_client.get_signature_status(&signature)?;
sourcepub fn get_signature_statuses(
&self,
signatures: &[Signature],
) -> RpcResult<Vec<Option<TransactionStatus>>>
pub fn get_signature_statuses( &self, signatures: &[Signature], ) -> RpcResult<Vec<Option<TransactionStatus>>>
Gets the statuses of a list of transaction signatures.
The returned vector of TransactionStatus
has the same length as the
input slice.
For any transaction that has not been processed by the network, the
value of the corresponding entry in the returned vector is None
. As a
result, a transaction that has recently been submitted will not have a
status immediately.
To submit a transaction and wait for it to confirm, use
send_and_confirm_transaction
.
This function ignores the configured confirmation level, and returns the transaction status whatever it is. It does not wait for transactions to be processed.
This function only searches a node’s recent history, including all
recent slots, plus up to
MAX_RECENT_BLOCKHASHES
rooted slots. To search the full transaction history use the
get_signature_statuses_with_history
method.
§Errors
Any individual TransactionStatus
may have triggered an error during
processing, in which case its err
field
will be Some
.
§RPC Reference
This method corresponds directly to the getSignatureStatuses
RPC method.
§Examples
// Send lamports from Alice to Bob and wait for the transaction to be processed
let latest_blockhash = rpc_client.get_latest_blockhash()?;
let tx = system_transaction::transfer(&alice, &bob.pubkey(), lamports, latest_blockhash);
let signature = rpc_client.send_transaction(&tx)?;
let status = loop {
let statuses = rpc_client.get_signature_statuses(&[signature])?.value;
if let Some(status) = statuses[0].clone() {
break status;
}
std::thread::sleep(Duration::from_millis(100));
};
assert!(status.err.is_none());
sourcepub fn get_signature_statuses_with_history(
&self,
signatures: &[Signature],
) -> RpcResult<Vec<Option<TransactionStatus>>>
pub fn get_signature_statuses_with_history( &self, signatures: &[Signature], ) -> RpcResult<Vec<Option<TransactionStatus>>>
Gets the statuses of a list of transaction signatures.
The returned vector of TransactionStatus
has the same length as the
input slice.
For any transaction that has not been processed by the network, the
value of the corresponding entry in the returned vector is None
. As a
result, a transaction that has recently been submitted will not have a
status immediately.
To submit a transaction and wait for it to confirm, use
send_and_confirm_transaction
.
This function ignores the configured confirmation level, and returns the transaction status whatever it is. It does not wait for transactions to be processed.
This function searches a node’s full ledger history and (if implemented) long-term storage. To search for
transactions in recent slots only use the
get_signature_statuses
method.
§Errors
Any individual TransactionStatus
may have triggered an error during
processing, in which case its err
field
will be Some
.
§RPC Reference
This method corresponds directly to the getSignatureStatuses
RPC
method, with the searchTransactionHistory
configuration option set to
true
.
§Examples
// Check if an old transaction exists
let signature = get_old_transaction_signature();
let latest_blockhash = rpc_client.get_latest_blockhash()?;
let statuses = rpc_client.get_signature_statuses_with_history(&[signature])?.value;
if statuses[0].is_none() {
println!("old transaction does not exist");
}
sourcepub fn get_signature_status_with_commitment(
&self,
signature: &Signature,
commitment_config: CommitmentConfig,
) -> ClientResult<Option<Result<()>>>
pub fn get_signature_status_with_commitment( &self, signature: &Signature, commitment_config: CommitmentConfig, ) -> ClientResult<Option<Result<()>>>
Check if a transaction has been processed with the given commitment level.
If the transaction has been processed with the given commitment level,
then this method returns Ok
of Some
. If the transaction has not yet
been processed with the given commitment level, it returns Ok
of
None
.
If the transaction has been processed with the given commitment level,
and the transaction succeeded, this method returns Ok(Some(Ok(())))
.
If the transaction has been processed with the given commitment level,
and the transaction failed, this method returns Ok(Some(Err(_)))
,
where the interior error is type TransactionError
.
This function only searches a node’s recent history, including all
recent slots, plus up to
MAX_RECENT_BLOCKHASHES
rooted slots. To search the full transaction history use the
get_signature_status_with_commitment_and_history
method.
§RPC Reference
This method is built on the getSignatureStatuses
RPC method.
§Examples
let signature = rpc_client.send_and_confirm_transaction(&tx)?;
let commitment_config = CommitmentConfig::processed();
let status = rpc_client.get_signature_status_with_commitment(
&signature,
commitment_config,
)?;
sourcepub fn get_signature_status_with_commitment_and_history(
&self,
signature: &Signature,
commitment_config: CommitmentConfig,
search_transaction_history: bool,
) -> ClientResult<Option<Result<()>>>
pub fn get_signature_status_with_commitment_and_history( &self, signature: &Signature, commitment_config: CommitmentConfig, search_transaction_history: bool, ) -> ClientResult<Option<Result<()>>>
Check if a transaction has been processed with the given commitment level.
If the transaction has been processed with the given commitment level,
then this method returns Ok
of Some
. If the transaction has not yet
been processed with the given commitment level, it returns Ok
of
None
.
If the transaction has been processed with the given commitment level,
and the transaction succeeded, this method returns Ok(Some(Ok(())))
.
If the transaction has been processed with the given commitment level,
and the transaction failed, this method returns Ok(Some(Err(_)))
,
where the interior error is type TransactionError
.
This method optionally searches a node’s full ledger history and (if implemented) long-term storage.
§RPC Reference
This method is built on the getSignatureStatuses
RPC method.
§Examples
let signature = rpc_client.send_transaction(&tx)?;
let commitment_config = CommitmentConfig::processed();
let search_transaction_history = true;
let status = rpc_client.get_signature_status_with_commitment_and_history(
&signature,
commitment_config,
search_transaction_history,
)?;
sourcepub fn get_slot(&self) -> ClientResult<Slot>
pub fn get_slot(&self) -> ClientResult<Slot>
Returns the slot that has reached the configured commitment level.
§RPC Reference
This method corresponds directly to the getSlot
RPC method.
§Examples
let slot = rpc_client.get_slot()?;
sourcepub fn get_slot_with_commitment(
&self,
commitment_config: CommitmentConfig,
) -> ClientResult<Slot>
pub fn get_slot_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<Slot>
Returns the slot that has reached the given commitment level.
§RPC Reference
This method corresponds directly to the getSlot
RPC method.
§Examples
let commitment_config = CommitmentConfig::processed();
let slot = rpc_client.get_slot_with_commitment(commitment_config)?;
sourcepub fn get_block_height(&self) -> ClientResult<u64>
pub fn get_block_height(&self) -> ClientResult<u64>
Returns the block height that has reached the configured commitment level.
§RPC Reference
This method is corresponds directly to the getBlockHeight
RPC method.
§Examples
let block_height = rpc_client.get_block_height()?;
sourcepub fn get_block_height_with_commitment(
&self,
commitment_config: CommitmentConfig,
) -> ClientResult<u64>
pub fn get_block_height_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<u64>
Returns the block height that has reached the given commitment level.
§RPC Reference
This method is corresponds directly to the getBlockHeight
RPC method.
§Examples
let commitment_config = CommitmentConfig::processed();
let block_height = rpc_client.get_block_height_with_commitment(
commitment_config,
)?;
sourcepub fn get_slot_leaders(
&self,
start_slot: Slot,
limit: u64,
) -> ClientResult<Vec<Pubkey>>
pub fn get_slot_leaders( &self, start_slot: Slot, limit: u64, ) -> ClientResult<Vec<Pubkey>>
Returns the slot leaders for a given slot range.
§RPC Reference
This method corresponds directly to the getSlotLeaders
RPC method.
§Examples
let start_slot = 1;
let limit = 3;
let leaders = rpc_client.get_slot_leaders(start_slot, limit)?;
sourcepub fn get_block_production(&self) -> RpcResult<RpcBlockProduction>
pub fn get_block_production(&self) -> RpcResult<RpcBlockProduction>
Get block production for the current epoch.
§RPC Reference
This method corresponds directly to the getBlockProduction
RPC method.
§Examples
let production = rpc_client.get_block_production()?;
sourcepub fn get_block_production_with_config(
&self,
config: RpcBlockProductionConfig,
) -> RpcResult<RpcBlockProduction>
pub fn get_block_production_with_config( &self, config: RpcBlockProductionConfig, ) -> RpcResult<RpcBlockProduction>
Get block production for the current or previous epoch.
§RPC Reference
This method corresponds directly to the getBlockProduction
RPC method.
§Examples
let leader = rpc_client.get_slot_leaders(start_slot, limit)?;
let leader = leader[0];
let range = RpcBlockProductionConfigRange {
first_slot: start_slot,
last_slot: Some(start_slot + limit),
};
let config = RpcBlockProductionConfig {
identity: Some(leader.to_string()),
range: Some(range),
commitment: Some(CommitmentConfig::processed()),
};
let production = rpc_client.get_block_production_with_config(
config
)?;
sourcepub fn get_stake_activation(
&self,
stake_account: Pubkey,
epoch: Option<Epoch>,
) -> ClientResult<RpcStakeActivation>
👎Deprecated since 1.18.18: Do not use; getStakeActivation is deprecated on the JSON-RPC server. Please use the stake account and StakeHistory sysvar to call Delegation::stake_activating_and_deactivating()
instead
pub fn get_stake_activation( &self, stake_account: Pubkey, epoch: Option<Epoch>, ) -> ClientResult<RpcStakeActivation>
Delegation::stake_activating_and_deactivating()
insteadReturns epoch activation information for a stake account.
This method uses the configured [commitment level].
§RPC Reference
This method corresponds directly to the getStakeActivation
RPC method.
§Examples
// Find some vote account to delegate to
let vote_accounts = rpc_client.get_vote_accounts()?;
let vote_account = vote_accounts.current.get(0).unwrap_or_else(|| &vote_accounts.delinquent[0]);
let vote_account_pubkey = &vote_account.vote_pubkey;
let vote_account_pubkey = Pubkey::from_str(vote_account_pubkey).expect("pubkey");
// Create a stake account
let stake_account = Keypair::new();
let stake_account_pubkey = stake_account.pubkey();
// Build the instructions to create new stake account,
// funded by alice, and delegate to a validator's vote account.
let instrs = stake::instruction::create_account_and_delegate_stake(
&alice.pubkey(),
&stake_account_pubkey,
&vote_account_pubkey,
&Authorized::auto(&stake_account_pubkey),
&Lockup::default(),
1_000_000,
);
let latest_blockhash = rpc_client.get_latest_blockhash()?;
let tx = Transaction::new_signed_with_payer(
&instrs,
Some(&alice.pubkey()),
&[&alice, &stake_account],
latest_blockhash,
);
rpc_client.send_and_confirm_transaction(&tx)?;
let epoch_info = rpc_client.get_epoch_info()?;
let activation = rpc_client.get_stake_activation(
stake_account_pubkey,
Some(epoch_info.epoch),
)?;
assert_eq!(activation.state, StakeActivationState::Activating);
sourcepub fn supply(&self) -> RpcResult<RpcSupply>
pub fn supply(&self) -> RpcResult<RpcSupply>
Returns information about the current supply.
This method uses the configured commitment level.
§RPC Reference
This method corresponds directly to the getSupply
RPC method.
§Examples
let supply = rpc_client.supply()?;
sourcepub fn supply_with_commitment(
&self,
commitment_config: CommitmentConfig,
) -> RpcResult<RpcSupply>
pub fn supply_with_commitment( &self, commitment_config: CommitmentConfig, ) -> RpcResult<RpcSupply>
sourcepub fn get_largest_accounts_with_config(
&self,
config: RpcLargestAccountsConfig,
) -> RpcResult<Vec<RpcAccountBalance>>
pub fn get_largest_accounts_with_config( &self, config: RpcLargestAccountsConfig, ) -> RpcResult<Vec<RpcAccountBalance>>
Returns the 20 largest accounts, by lamport balance.
§RPC Reference
This method corresponds directly to the getLargestAccounts
RPC
method.
§Examples
let commitment_config = CommitmentConfig::processed();
let config = RpcLargestAccountsConfig {
commitment: Some(commitment_config),
filter: Some(RpcLargestAccountsFilter::Circulating),
};
let accounts = rpc_client.get_largest_accounts_with_config(
config,
)?;
sourcepub fn get_vote_accounts(&self) -> ClientResult<RpcVoteAccountStatus>
pub fn get_vote_accounts(&self) -> ClientResult<RpcVoteAccountStatus>
Returns the account info and associated stake for all the voting accounts that have reached the configured commitment level.
§RPC Reference
This method corresponds directly to the getVoteAccounts
RPC method.
§Examples
let accounts = rpc_client.get_vote_accounts()?;
sourcepub fn get_vote_accounts_with_commitment(
&self,
commitment_config: CommitmentConfig,
) -> ClientResult<RpcVoteAccountStatus>
pub fn get_vote_accounts_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<RpcVoteAccountStatus>
Returns the account info and associated stake for all the voting accounts that have reached the given commitment level.
§RPC Reference
This method corresponds directly to the getVoteAccounts
RPC method.
§Examples
let commitment_config = CommitmentConfig::processed();
let accounts = rpc_client.get_vote_accounts_with_commitment(
commitment_config,
)?;
sourcepub fn get_vote_accounts_with_config(
&self,
config: RpcGetVoteAccountsConfig,
) -> ClientResult<RpcVoteAccountStatus>
pub fn get_vote_accounts_with_config( &self, config: RpcGetVoteAccountsConfig, ) -> ClientResult<RpcVoteAccountStatus>
Returns the account info and associated stake for all the voting accounts that have reached the given commitment level.
§RPC Reference
This method corresponds directly to the getVoteAccounts
RPC method.
§Examples
let vote_pubkey = vote_keypair.pubkey();
let commitment = CommitmentConfig::processed();
let config = RpcGetVoteAccountsConfig {
vote_pubkey: Some(vote_pubkey.to_string()),
commitment: Some(commitment),
keep_unstaked_delinquents: Some(true),
delinquent_slot_distance: Some(10),
};
let accounts = rpc_client.get_vote_accounts_with_config(
config,
)?;
pub fn wait_for_max_stake( &self, commitment: CommitmentConfig, max_stake_percent: f32, ) -> ClientResult<()>
sourcepub fn get_cluster_nodes(&self) -> ClientResult<Vec<RpcContactInfo>>
pub fn get_cluster_nodes(&self) -> ClientResult<Vec<RpcContactInfo>>
Returns information about all the nodes participating in the cluster.
§RPC Reference
This method corresponds directly to the getClusterNodes
RPC method.
§Examples
let cluster_nodes = rpc_client.get_cluster_nodes()?;
sourcepub fn get_block(&self, slot: Slot) -> ClientResult<EncodedConfirmedBlock>
pub fn get_block(&self, slot: Slot) -> ClientResult<EncodedConfirmedBlock>
Returns identity and transaction information about a confirmed block in the ledger.
The encodings are returned in UiTransactionEncoding::Json
format. To return transactions in other encodings, use
get_block_with_encoding
.
§RPC Reference
This method corresponds directly to the getBlock
RPC
method.
§Examples
let block = rpc_client.get_block(slot)?;
sourcepub fn get_block_with_encoding(
&self,
slot: Slot,
encoding: UiTransactionEncoding,
) -> ClientResult<EncodedConfirmedBlock>
pub fn get_block_with_encoding( &self, slot: Slot, encoding: UiTransactionEncoding, ) -> ClientResult<EncodedConfirmedBlock>
sourcepub fn get_block_with_config(
&self,
slot: Slot,
config: RpcBlockConfig,
) -> ClientResult<UiConfirmedBlock>
pub fn get_block_with_config( &self, slot: Slot, config: RpcBlockConfig, ) -> ClientResult<UiConfirmedBlock>
Returns identity and transaction information about a confirmed block in the ledger.
§RPC Reference
This method corresponds directly to the getBlock
RPC method.
§Examples
let config = RpcBlockConfig {
encoding: Some(UiTransactionEncoding::Base58),
transaction_details: Some(TransactionDetails::None),
rewards: Some(true),
commitment: None,
max_supported_transaction_version: Some(0),
};
let block = rpc_client.get_block_with_config(
slot,
config,
)?;
pub fn get_confirmed_block( &self, slot: Slot, ) -> ClientResult<EncodedConfirmedBlock>
pub fn get_confirmed_block_with_encoding( &self, slot: Slot, encoding: UiTransactionEncoding, ) -> ClientResult<EncodedConfirmedBlock>
pub fn get_confirmed_block_with_config( &self, slot: Slot, config: RpcConfirmedBlockConfig, ) -> ClientResult<UiConfirmedBlock>
sourcepub fn get_blocks(
&self,
start_slot: Slot,
end_slot: Option<Slot>,
) -> ClientResult<Vec<Slot>>
pub fn get_blocks( &self, start_slot: Slot, end_slot: Option<Slot>, ) -> ClientResult<Vec<Slot>>
Returns a list of finalized blocks between two slots.
The range is inclusive, with results including the block for both
start_slot
and end_slot
.
If end_slot
is not provided, then the end slot is for the latest
finalized block.
This method may not return blocks for the full range of slots if some
slots do not have corresponding blocks. To simply get a specific number
of sequential blocks, use the get_blocks_with_limit
method.
This method uses the Finalized
commitment level.
§Errors
This method returns an error if the range is greater than 500,000 slots.
§RPC Reference
This method corresponds directly to the getBlocks
RPC method, unless
the remote node version is less than 1.7, in which case it maps to the
getConfirmedBlocks
RPC method.
§Examples
// Get up to the first 10 blocks
let start_slot = 0;
let end_slot = 9;
let blocks = rpc_client.get_blocks(start_slot, Some(end_slot))?;
sourcepub fn get_blocks_with_commitment(
&self,
start_slot: Slot,
end_slot: Option<Slot>,
commitment_config: CommitmentConfig,
) -> ClientResult<Vec<Slot>>
pub fn get_blocks_with_commitment( &self, start_slot: Slot, end_slot: Option<Slot>, commitment_config: CommitmentConfig, ) -> ClientResult<Vec<Slot>>
Returns a list of confirmed blocks between two slots.
The range is inclusive, with results including the block for both
start_slot
and end_slot
.
If end_slot
is not provided, then the end slot is for the latest
block with the given commitment level.
This method may not return blocks for the full range of slots if some
slots do not have corresponding blocks. To simply get a specific number
of sequential blocks, use the get_blocks_with_limit_and_commitment
method.
§Errors
This method returns an error if the range is greater than 500,000 slots.
This method returns an error if the given commitment level is below
Confirmed
.
§RPC Reference
This method corresponds directly to the getBlocks
RPC method, unless
the remote node version is less than 1.7, in which case it maps to the
getConfirmedBlocks
RPC method.
§Examples
// Get up to the first 10 blocks
let start_slot = 0;
let end_slot = 9;
// Method does not support commitment below `confirmed`
let commitment_config = CommitmentConfig::confirmed();
let blocks = rpc_client.get_blocks_with_commitment(
start_slot,
Some(end_slot),
commitment_config,
)?;
sourcepub fn get_blocks_with_limit(
&self,
start_slot: Slot,
limit: usize,
) -> ClientResult<Vec<Slot>>
pub fn get_blocks_with_limit( &self, start_slot: Slot, limit: usize, ) -> ClientResult<Vec<Slot>>
Returns a list of finalized blocks starting at the given slot.
This method uses the Finalized
commitment level.
§Errors
This method returns an error if the limit is greater than 500,000 slots.
§RPC Reference
This method corresponds directly to the getBlocksWithLimit
RPC
method, unless the remote node version is less than 1.7, in which case
it maps to the getConfirmedBlocksWithLimit
RPC method.
§Examples
// Get the first 10 blocks
let start_slot = 0;
let limit = 10;
let blocks = rpc_client.get_blocks_with_limit(start_slot, limit)?;
sourcepub fn get_blocks_with_limit_and_commitment(
&self,
start_slot: Slot,
limit: usize,
commitment_config: CommitmentConfig,
) -> ClientResult<Vec<Slot>>
pub fn get_blocks_with_limit_and_commitment( &self, start_slot: Slot, limit: usize, commitment_config: CommitmentConfig, ) -> ClientResult<Vec<Slot>>
Returns a list of confirmed blocks starting at the given slot.
§Errors
This method returns an error if the limit is greater than 500,000 slots.
This method returns an error if the given commitment level is below
Confirmed
.
§RPC Reference
This method corresponds directly to the getBlocksWithLimit
RPC
method, unless the remote node version is less than 1.7, in which case
it maps to the getConfirmedBlocksWithLimit
RPC method.
§Examples
// Get the first 10 blocks
let start_slot = 0;
let limit = 10;
let commitment_config = CommitmentConfig::confirmed();
let blocks = rpc_client.get_blocks_with_limit_and_commitment(
start_slot,
limit,
commitment_config,
)?;
pub fn get_confirmed_blocks( &self, start_slot: Slot, end_slot: Option<Slot>, ) -> ClientResult<Vec<Slot>>
pub fn get_confirmed_blocks_with_commitment( &self, start_slot: Slot, end_slot: Option<Slot>, commitment_config: CommitmentConfig, ) -> ClientResult<Vec<Slot>>
pub fn get_confirmed_blocks_with_limit( &self, start_slot: Slot, limit: usize, ) -> ClientResult<Vec<Slot>>
pub fn get_confirmed_blocks_with_limit_and_commitment( &self, start_slot: Slot, limit: usize, commitment_config: CommitmentConfig, ) -> ClientResult<Vec<Slot>>
sourcepub fn get_signatures_for_address(
&self,
address: &Pubkey,
) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>>
pub fn get_signatures_for_address( &self, address: &Pubkey, ) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>>
Get confirmed signatures for transactions involving an address.
Returns up to 1000 signatures, ordered from newest to oldest.
This method uses the Finalized
commitment level.
§RPC Reference
This method corresponds directly to the getSignaturesForAddress
RPC
method.
§Examples
let signatures = rpc_client.get_signatures_for_address(
&alice.pubkey(),
)?;
sourcepub fn get_signatures_for_address_with_config(
&self,
address: &Pubkey,
config: GetConfirmedSignaturesForAddress2Config,
) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>>
pub fn get_signatures_for_address_with_config( &self, address: &Pubkey, config: GetConfirmedSignaturesForAddress2Config, ) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>>
Get confirmed signatures for transactions involving an address.
§Errors
This method returns an error if the given commitment level is below
Confirmed
.
§RPC Reference
This method corresponds directly to the getSignaturesForAddress
RPC
method.
§Examples
let config = GetConfirmedSignaturesForAddress2Config {
before: None,
until: None,
limit: Some(3),
commitment: Some(CommitmentConfig::confirmed()),
};
let signatures = rpc_client.get_signatures_for_address_with_config(
&alice.pubkey(),
config,
)?;
pub fn get_confirmed_signatures_for_address2( &self, address: &Pubkey, ) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>>
pub fn get_confirmed_signatures_for_address2_with_config( &self, address: &Pubkey, config: GetConfirmedSignaturesForAddress2Config, ) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>>
sourcepub fn get_transaction(
&self,
signature: &Signature,
encoding: UiTransactionEncoding,
) -> ClientResult<EncodedConfirmedTransactionWithStatusMeta>
pub fn get_transaction( &self, signature: &Signature, encoding: UiTransactionEncoding, ) -> ClientResult<EncodedConfirmedTransactionWithStatusMeta>
Returns transaction details for a confirmed transaction.
This method uses the Finalized
commitment level.
§RPC Reference
This method corresponds directly to the getTransaction
RPC method,
unless the remote node version is less than 1.7, in which case it maps
to the getConfirmedTransaction
RPC method.
§Examples
let signature = rpc_client.send_and_confirm_transaction(&tx)?;
let transaction = rpc_client.get_transaction(
&signature,
UiTransactionEncoding::Json,
)?;
sourcepub fn get_transaction_with_config(
&self,
signature: &Signature,
config: RpcTransactionConfig,
) -> ClientResult<EncodedConfirmedTransactionWithStatusMeta>
pub fn get_transaction_with_config( &self, signature: &Signature, config: RpcTransactionConfig, ) -> ClientResult<EncodedConfirmedTransactionWithStatusMeta>
Returns transaction details for a confirmed transaction.
§Errors
This method returns an error if the given commitment level is below
Confirmed
.
§RPC Reference
This method corresponds directly to the getTransaction
RPC method,
unless the remote node version is less than 1.7, in which case it maps
to the getConfirmedTransaction
RPC method.
§Examples
let signature = rpc_client.send_and_confirm_transaction(&tx)?;
let config = RpcTransactionConfig {
encoding: Some(UiTransactionEncoding::Json),
commitment: Some(CommitmentConfig::confirmed()),
max_supported_transaction_version: Some(0),
};
let transaction = rpc_client.get_transaction_with_config(
&signature,
config,
)?;
pub fn get_confirmed_transaction( &self, signature: &Signature, encoding: UiTransactionEncoding, ) -> ClientResult<EncodedConfirmedTransactionWithStatusMeta>
pub fn get_confirmed_transaction_with_config( &self, signature: &Signature, config: RpcConfirmedTransactionConfig, ) -> ClientResult<EncodedConfirmedTransactionWithStatusMeta>
sourcepub fn get_block_time(&self, slot: Slot) -> ClientResult<UnixTimestamp>
pub fn get_block_time(&self, slot: Slot) -> ClientResult<UnixTimestamp>
Returns the estimated production time of a block.
§RPC Reference
This method corresponds directly to the getBlockTime
RPC method.
§Examples
// Get the time of the most recent finalized block
let slot = rpc_client.get_slot()?;
let block_time = rpc_client.get_block_time(slot)?;
sourcepub fn get_epoch_info(&self) -> ClientResult<EpochInfo>
pub fn get_epoch_info(&self) -> ClientResult<EpochInfo>
Returns information about the current epoch.
This method uses the configured default commitment level.
§RPC Reference
This method corresponds directly to the getEpochInfo
RPC method.
§Examples
let epoch_info = rpc_client.get_epoch_info()?;
sourcepub fn get_epoch_info_with_commitment(
&self,
commitment_config: CommitmentConfig,
) -> ClientResult<EpochInfo>
pub fn get_epoch_info_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<EpochInfo>
Returns information about the current epoch.
§RPC Reference
This method corresponds directly to the getEpochInfo
RPC method.
§Examples
let commitment_config = CommitmentConfig::confirmed();
let epoch_info = rpc_client.get_epoch_info_with_commitment(
commitment_config,
)?;
sourcepub fn get_leader_schedule(
&self,
slot: Option<Slot>,
) -> ClientResult<Option<RpcLeaderSchedule>>
pub fn get_leader_schedule( &self, slot: Option<Slot>, ) -> ClientResult<Option<RpcLeaderSchedule>>
Returns the leader schedule for an epoch.
This method uses the configured default commitment level.
§RPC Reference
This method corresponds directly to the getLeaderSchedule
RPC method.
§Examples
let leader_schedule = rpc_client.get_leader_schedule(
Some(slot),
)?;
sourcepub fn get_leader_schedule_with_commitment(
&self,
slot: Option<Slot>,
commitment_config: CommitmentConfig,
) -> ClientResult<Option<RpcLeaderSchedule>>
pub fn get_leader_schedule_with_commitment( &self, slot: Option<Slot>, commitment_config: CommitmentConfig, ) -> ClientResult<Option<RpcLeaderSchedule>>
Returns the leader schedule for an epoch.
§RPC Reference
This method corresponds directly to the getLeaderSchedule
RPC method.
§Examples
let commitment_config = CommitmentConfig::processed();
let leader_schedule = rpc_client.get_leader_schedule_with_commitment(
Some(slot),
commitment_config,
)?;
sourcepub fn get_leader_schedule_with_config(
&self,
slot: Option<Slot>,
config: RpcLeaderScheduleConfig,
) -> ClientResult<Option<RpcLeaderSchedule>>
pub fn get_leader_schedule_with_config( &self, slot: Option<Slot>, config: RpcLeaderScheduleConfig, ) -> ClientResult<Option<RpcLeaderSchedule>>
Returns the leader schedule for an epoch.
§RPC Reference
This method corresponds directly to the getLeaderSchedule
RPC method.
§Examples
let config = RpcLeaderScheduleConfig {
identity: Some(validator_pubkey_str),
commitment: Some(CommitmentConfig::processed()),
};
let leader_schedule = rpc_client.get_leader_schedule_with_config(
Some(slot),
config,
)?;
sourcepub fn get_epoch_schedule(&self) -> ClientResult<EpochSchedule>
pub fn get_epoch_schedule(&self) -> ClientResult<EpochSchedule>
Returns epoch schedule information from this cluster’s genesis config.
§RPC Reference
This method corresponds directly to the getEpochSchedule
RPC method.
§Examples
let epoch_schedule = rpc_client.get_epoch_schedule()?;
sourcepub fn get_recent_performance_samples(
&self,
limit: Option<usize>,
) -> ClientResult<Vec<RpcPerfSample>>
pub fn get_recent_performance_samples( &self, limit: Option<usize>, ) -> ClientResult<Vec<RpcPerfSample>>
Returns a list of recent performance samples, in reverse slot order.
Performance samples are taken every 60 seconds and include the number of transactions and slots that occur in a given time window.
§RPC Reference
This method corresponds directly to the getRecentPerformanceSamples
RPC method.
§Examples
let limit = 10;
let performance_samples = rpc_client.get_recent_performance_samples(
Some(limit),
)?;
sourcepub fn get_recent_prioritization_fees(
&self,
addresses: &[Pubkey],
) -> ClientResult<Vec<RpcPrioritizationFee>>
pub fn get_recent_prioritization_fees( &self, addresses: &[Pubkey], ) -> ClientResult<Vec<RpcPrioritizationFee>>
Returns a list of minimum prioritization fees from recent blocks. Takes an optional vector of addresses; if any addresses are provided, the response will reflect the minimum prioritization fee to land a transaction locking all of the provided accounts as writable.
Currently, a node’s prioritization-fee cache stores data from up to 150 blocks.
§RPC Reference
This method corresponds directly to the getRecentPrioritizationFees
RPC method.
§Examples
let addresses = vec![alice.pubkey(), bob.pubkey()];
let prioritization_fees = rpc_client.get_recent_prioritization_fees(
&addresses,
)?;
sourcepub fn get_identity(&self) -> ClientResult<Pubkey>
pub fn get_identity(&self) -> ClientResult<Pubkey>
Returns the identity pubkey for the current node.
§RPC Reference
This method corresponds directly to the getIdentity
RPC method.
§Examples
let identity = rpc_client.get_identity()?;
sourcepub fn get_inflation_governor(&self) -> ClientResult<RpcInflationGovernor>
pub fn get_inflation_governor(&self) -> ClientResult<RpcInflationGovernor>
Returns the current inflation governor.
This method uses the Finalized
commitment level.
§RPC Reference
This method corresponds directly to the getInflationGovernor
RPC
method.
§Examples
let inflation_governor = rpc_client.get_inflation_governor()?;
sourcepub fn get_inflation_rate(&self) -> ClientResult<RpcInflationRate>
pub fn get_inflation_rate(&self) -> ClientResult<RpcInflationRate>
Returns the specific inflation values for the current epoch.
§RPC Reference
This method corresponds directly to the getInflationRate
RPC method.
§Examples
let inflation_rate = rpc_client.get_inflation_rate()?;
sourcepub fn get_inflation_reward(
&self,
addresses: &[Pubkey],
epoch: Option<Epoch>,
) -> ClientResult<Vec<Option<RpcInflationReward>>>
pub fn get_inflation_reward( &self, addresses: &[Pubkey], epoch: Option<Epoch>, ) -> ClientResult<Vec<Option<RpcInflationReward>>>
Returns the inflation reward for a list of addresses for an epoch.
This method uses the configured commitment level.
§RPC Reference
This method corresponds directly to the getInflationReward
RPC method.
§Examples
let addresses = vec![alice.pubkey(), bob.pubkey()];
let inflation_reward = rpc_client.get_inflation_reward(
&addresses,
Some(epoch),
)?;
sourcepub fn get_version(&self) -> ClientResult<RpcVersionInfo>
pub fn get_version(&self) -> ClientResult<RpcVersionInfo>
Returns the current solana version running on the node.
§RPC Reference
This method corresponds directly to the getVersion
RPC method.
§Examples
let expected_version = semver::Version::new(1, 7, 0);
let version = rpc_client.get_version()?;
let version = semver::Version::parse(&version.solana_core)?;
assert!(version >= expected_version);
sourcepub fn minimum_ledger_slot(&self) -> ClientResult<Slot>
pub fn minimum_ledger_slot(&self) -> ClientResult<Slot>
Returns the lowest slot that the node has information about in its ledger.
This value may increase over time if the node is configured to purge older ledger data.
§RPC Reference
This method corresponds directly to the minimumLedgerSlot
RPC
method.
§Examples
let slot = rpc_client.minimum_ledger_slot()?;
sourcepub fn get_account(&self, pubkey: &Pubkey) -> ClientResult<Account>
pub fn get_account(&self, pubkey: &Pubkey) -> ClientResult<Account>
Returns all information associated with the account of the provided pubkey.
This method uses the configured commitment level.
To get multiple accounts at once, use the get_multiple_accounts
method.
§Errors
If the account does not exist, this method returns
RpcError::ForUser
. This is unlike get_account_with_commitment
,
which returns Ok(None)
if the account does not exist.
§RPC Reference
This method is built on the getAccountInfo
RPC method.
§Examples
let alice_pubkey = Pubkey::from_str("BgvYtJEfmZYdVKiptmMjxGzv8iQoo4MWjsP3QsTkhhxa").unwrap();
let account = rpc_client.get_account(&alice_pubkey)?;
sourcepub fn get_account_with_commitment(
&self,
pubkey: &Pubkey,
commitment_config: CommitmentConfig,
) -> RpcResult<Option<Account>>
pub fn get_account_with_commitment( &self, pubkey: &Pubkey, commitment_config: CommitmentConfig, ) -> RpcResult<Option<Account>>
Returns all information associated with the account of the provided pubkey.
If the account does not exist, this method returns Ok(None)
.
To get multiple accounts at once, use the get_multiple_accounts_with_commitment
method.
§RPC Reference
This method is built on the getAccountInfo
RPC method.
§Examples
let alice_pubkey = Pubkey::from_str("BgvYtJEfmZYdVKiptmMjxGzv8iQoo4MWjsP3QsTkhhxa").unwrap();
let commitment_config = CommitmentConfig::processed();
let account = rpc_client.get_account_with_commitment(
&alice_pubkey,
commitment_config,
)?;
assert!(account.value.is_some());
sourcepub fn get_account_with_config(
&self,
pubkey: &Pubkey,
config: RpcAccountInfoConfig,
) -> RpcResult<Option<Account>>
pub fn get_account_with_config( &self, pubkey: &Pubkey, config: RpcAccountInfoConfig, ) -> RpcResult<Option<Account>>
Returns all information associated with the account of the provided pubkey.
If the account does not exist, this method returns Ok(None)
.
To get multiple accounts at once, use the get_multiple_accounts_with_config
method.
§RPC Reference
This method is built on the getAccountInfo
RPC method.
§Examples
let alice_pubkey = Pubkey::from_str("BgvYtJEfmZYdVKiptmMjxGzv8iQoo4MWjsP3QsTkhhxa").unwrap();
let commitment_config = CommitmentConfig::processed();
let config = RpcAccountInfoConfig {
encoding: Some(UiAccountEncoding::Base64),
commitment: Some(commitment_config),
.. RpcAccountInfoConfig::default()
};
let account = rpc_client.get_account_with_config(
&alice_pubkey,
config,
)?;
assert!(account.value.is_some());
sourcepub fn get_max_retransmit_slot(&self) -> ClientResult<Slot>
pub fn get_max_retransmit_slot(&self) -> ClientResult<Slot>
Get the max slot seen from retransmit stage.
§RPC Reference
This method corresponds directly to the getMaxRetransmitSlot
RPC
method.
§Examples
let slot = rpc_client.get_max_retransmit_slot()?;
sourcepub fn get_max_shred_insert_slot(&self) -> ClientResult<Slot>
pub fn get_max_shred_insert_slot(&self) -> ClientResult<Slot>
Get the max slot seen from after shred insert.
§RPC Reference
This method corresponds directly to the
getMaxShredInsertSlot
RPC method.
§Examples
let slot = rpc_client.get_max_shred_insert_slot()?;
sourcepub fn get_multiple_accounts(
&self,
pubkeys: &[Pubkey],
) -> ClientResult<Vec<Option<Account>>>
pub fn get_multiple_accounts( &self, pubkeys: &[Pubkey], ) -> ClientResult<Vec<Option<Account>>>
Returns the account information for a list of pubkeys.
This method uses the configured commitment level.
§RPC Reference
This method is built on the getMultipleAccounts
RPC method.
§Examples
let pubkeys = vec![alice.pubkey(), bob.pubkey()];
let accounts = rpc_client.get_multiple_accounts(&pubkeys)?;
sourcepub fn get_multiple_accounts_with_commitment(
&self,
pubkeys: &[Pubkey],
commitment_config: CommitmentConfig,
) -> RpcResult<Vec<Option<Account>>>
pub fn get_multiple_accounts_with_commitment( &self, pubkeys: &[Pubkey], commitment_config: CommitmentConfig, ) -> RpcResult<Vec<Option<Account>>>
Returns the account information for a list of pubkeys.
§RPC Reference
This method is built on the getMultipleAccounts
RPC method.
§Examples
let pubkeys = vec![alice.pubkey(), bob.pubkey()];
let commitment_config = CommitmentConfig::processed();
let accounts = rpc_client.get_multiple_accounts_with_commitment(
&pubkeys,
commitment_config,
)?;
sourcepub fn get_multiple_accounts_with_config(
&self,
pubkeys: &[Pubkey],
config: RpcAccountInfoConfig,
) -> RpcResult<Vec<Option<Account>>>
pub fn get_multiple_accounts_with_config( &self, pubkeys: &[Pubkey], config: RpcAccountInfoConfig, ) -> RpcResult<Vec<Option<Account>>>
Returns the account information for a list of pubkeys.
§RPC Reference
This method is built on the getMultipleAccounts
RPC method.
§Examples
let pubkeys = vec![alice.pubkey(), bob.pubkey()];
let commitment_config = CommitmentConfig::processed();
let config = RpcAccountInfoConfig {
encoding: Some(UiAccountEncoding::Base64),
commitment: Some(commitment_config),
.. RpcAccountInfoConfig::default()
};
let accounts = rpc_client.get_multiple_accounts_with_config(
&pubkeys,
config,
)?;
sourcepub fn get_account_data(&self, pubkey: &Pubkey) -> ClientResult<Vec<u8>>
pub fn get_account_data(&self, pubkey: &Pubkey) -> ClientResult<Vec<u8>>
Gets the raw data associated with an account.
This is equivalent to calling get_account
and then accessing the
data
field of the returned Account
.
§RPC Reference
This method is built on the getAccountInfo
RPC method.
§Examples
let alice_pubkey = Pubkey::from_str("BgvYtJEfmZYdVKiptmMjxGzv8iQoo4MWjsP3QsTkhhxa").unwrap();
let account_data = rpc_client.get_account_data(&alice_pubkey)?;
sourcepub fn get_minimum_balance_for_rent_exemption(
&self,
data_len: usize,
) -> ClientResult<u64>
pub fn get_minimum_balance_for_rent_exemption( &self, data_len: usize, ) -> ClientResult<u64>
Returns minimum balance required to make an account with specified data length rent exempt.
§RPC Reference
This method corresponds directly to the
getMinimumBalanceForRentExemption
RPC method.
§Examples
let data_len = 300;
let balance = rpc_client.get_minimum_balance_for_rent_exemption(data_len)?;
sourcepub fn get_balance(&self, pubkey: &Pubkey) -> ClientResult<u64>
pub fn get_balance(&self, pubkey: &Pubkey) -> ClientResult<u64>
Request the balance of the provided account pubkey.
This method uses the configured commitment level.
§RPC Reference
This method corresponds directly to the getBalance
RPC method.
§Examples
let balance = rpc_client.get_balance(&alice.pubkey())?;
sourcepub fn get_balance_with_commitment(
&self,
pubkey: &Pubkey,
commitment_config: CommitmentConfig,
) -> RpcResult<u64>
pub fn get_balance_with_commitment( &self, pubkey: &Pubkey, commitment_config: CommitmentConfig, ) -> RpcResult<u64>
Request the balance of the provided account pubkey.
§RPC Reference
This method corresponds directly to the getBalance
RPC method.
§Examples
let commitment_config = CommitmentConfig::processed();
let balance = rpc_client.get_balance_with_commitment(
&alice.pubkey(),
commitment_config,
)?;
sourcepub fn get_program_accounts(
&self,
pubkey: &Pubkey,
) -> ClientResult<Vec<(Pubkey, Account)>>
pub fn get_program_accounts( &self, pubkey: &Pubkey, ) -> ClientResult<Vec<(Pubkey, Account)>>
Returns all accounts owned by the provided program pubkey.
This method uses the configured commitment level.
§RPC Reference
This method corresponds directly to the getProgramAccounts
RPC
method.
§Examples
let accounts = rpc_client.get_program_accounts(&alice.pubkey())?;
sourcepub fn get_program_accounts_with_config(
&self,
pubkey: &Pubkey,
config: RpcProgramAccountsConfig,
) -> ClientResult<Vec<(Pubkey, Account)>>
pub fn get_program_accounts_with_config( &self, pubkey: &Pubkey, config: RpcProgramAccountsConfig, ) -> ClientResult<Vec<(Pubkey, Account)>>
Returns all accounts owned by the provided program pubkey.
§RPC Reference
This method is built on the getProgramAccounts
RPC method.
§Examples
let memcmp = RpcFilterType::Memcmp(Memcmp::new(
0, // offset
MemcmpEncodedBytes::Base64(base64_bytes.to_string()), // encoded bytes
));
let config = RpcProgramAccountsConfig {
filters: Some(vec![
RpcFilterType::DataSize(128),
memcmp,
]),
account_config: RpcAccountInfoConfig {
encoding: Some(UiAccountEncoding::Base64),
data_slice: Some(UiDataSliceConfig {
offset: 0,
length: 5,
}),
commitment: Some(CommitmentConfig::processed()),
min_context_slot: Some(1234),
},
with_context: Some(false),
};
let accounts = rpc_client.get_program_accounts_with_config(
&alice.pubkey(),
config,
)?;
sourcepub fn get_stake_minimum_delegation(&self) -> ClientResult<u64>
pub fn get_stake_minimum_delegation(&self) -> ClientResult<u64>
Returns the stake minimum delegation, in lamports.
§RPC Reference
This method corresponds directly to the getStakeMinimumDelegation
RPC method.
§Examples
let stake_minimum_delegation = rpc_client.get_stake_minimum_delegation()?;
sourcepub fn get_stake_minimum_delegation_with_commitment(
&self,
commitment_config: CommitmentConfig,
) -> ClientResult<u64>
pub fn get_stake_minimum_delegation_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<u64>
Returns the stake minimum delegation, in lamports, based on the commitment level.
§RPC Reference
This method corresponds directly to the getStakeMinimumDelegation
RPC method.
§Examples
let stake_minimum_delegation =
rpc_client.get_stake_minimum_delegation_with_commitment(CommitmentConfig::confirmed())?;
sourcepub fn get_transaction_count(&self) -> ClientResult<u64>
pub fn get_transaction_count(&self) -> ClientResult<u64>
Request the transaction count.
pub fn get_transaction_count_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<u64>
pub fn get_fees(&self) -> ClientResult<Fees>
get_latest_blockhash
and get_fee_for_message
insteadpub fn get_fees_with_commitment( &self, commitment_config: CommitmentConfig, ) -> RpcResult<Fees>
get_latest_blockhash_with_commitment
and get_fee_for_message
insteadpub fn get_recent_blockhash(&self) -> ClientResult<(Hash, FeeCalculator)>
get_latest_blockhash
insteadpub fn get_recent_blockhash_with_commitment( &self, commitment_config: CommitmentConfig, ) -> RpcResult<(Hash, FeeCalculator, Slot)>
get_latest_blockhash_with_commitment
insteadpub fn get_fee_calculator_for_blockhash( &self, blockhash: &Hash, ) -> ClientResult<Option<FeeCalculator>>
get_fee_for_message
insteadpub fn get_fee_calculator_for_blockhash_with_commitment( &self, blockhash: &Hash, commitment_config: CommitmentConfig, ) -> RpcResult<Option<FeeCalculator>>
get_latest_blockhash_with_commitment
and get_fee_for_message
insteadpub fn get_fee_rate_governor(&self) -> RpcResult<FeeRateGovernor>
pub fn get_new_blockhash( &self, blockhash: &Hash, ) -> ClientResult<(Hash, FeeCalculator)>
pub fn get_first_available_block(&self) -> ClientResult<Slot>
pub fn get_genesis_hash(&self) -> ClientResult<Hash>
pub fn get_health(&self) -> ClientResult<()>
pub fn get_token_account( &self, pubkey: &Pubkey, ) -> ClientResult<Option<UiTokenAccount>>
pub fn get_token_account_with_commitment( &self, pubkey: &Pubkey, commitment_config: CommitmentConfig, ) -> RpcResult<Option<UiTokenAccount>>
pub fn get_token_account_balance( &self, pubkey: &Pubkey, ) -> ClientResult<UiTokenAmount>
pub fn get_token_account_balance_with_commitment( &self, pubkey: &Pubkey, commitment_config: CommitmentConfig, ) -> RpcResult<UiTokenAmount>
pub fn get_token_accounts_by_delegate( &self, delegate: &Pubkey, token_account_filter: TokenAccountsFilter, ) -> ClientResult<Vec<RpcKeyedAccount>>
pub fn get_token_accounts_by_delegate_with_commitment( &self, delegate: &Pubkey, token_account_filter: TokenAccountsFilter, commitment_config: CommitmentConfig, ) -> RpcResult<Vec<RpcKeyedAccount>>
pub fn get_token_accounts_by_owner( &self, owner: &Pubkey, token_account_filter: TokenAccountsFilter, ) -> ClientResult<Vec<RpcKeyedAccount>>
pub fn get_token_accounts_by_owner_with_commitment( &self, owner: &Pubkey, token_account_filter: TokenAccountsFilter, commitment_config: CommitmentConfig, ) -> RpcResult<Vec<RpcKeyedAccount>>
pub fn get_token_largest_accounts( &self, mint: &Pubkey, ) -> ClientResult<Vec<RpcTokenAccountBalance>>
pub fn get_token_largest_accounts_with_commitment( &self, mint: &Pubkey, commitment_config: CommitmentConfig, ) -> RpcResult<Vec<RpcTokenAccountBalance>>
pub fn get_token_supply(&self, mint: &Pubkey) -> ClientResult<UiTokenAmount>
pub fn get_token_supply_with_commitment( &self, mint: &Pubkey, commitment_config: CommitmentConfig, ) -> RpcResult<UiTokenAmount>
pub fn request_airdrop( &self, pubkey: &Pubkey, lamports: u64, ) -> ClientResult<Signature>
pub fn request_airdrop_with_blockhash( &self, pubkey: &Pubkey, lamports: u64, recent_blockhash: &Hash, ) -> ClientResult<Signature>
pub fn request_airdrop_with_config( &self, pubkey: &Pubkey, lamports: u64, config: RpcRequestAirdropConfig, ) -> ClientResult<Signature>
pub fn poll_get_balance_with_commitment( &self, pubkey: &Pubkey, commitment_config: CommitmentConfig, ) -> ClientResult<u64>
pub fn wait_for_balance_with_commitment( &self, pubkey: &Pubkey, expected_balance: Option<u64>, commitment_config: CommitmentConfig, ) -> Option<u64>
sourcepub fn poll_for_signature(&self, signature: &Signature) -> ClientResult<()>
pub fn poll_for_signature(&self, signature: &Signature) -> ClientResult<()>
Poll the server to confirm a transaction.
sourcepub fn poll_for_signature_with_commitment(
&self,
signature: &Signature,
commitment_config: CommitmentConfig,
) -> ClientResult<()>
pub fn poll_for_signature_with_commitment( &self, signature: &Signature, commitment_config: CommitmentConfig, ) -> ClientResult<()>
Poll the server to confirm a transaction.
sourcepub fn poll_for_signature_confirmation(
&self,
signature: &Signature,
min_confirmed_blocks: usize,
) -> ClientResult<usize>
pub fn poll_for_signature_confirmation( &self, signature: &Signature, min_confirmed_blocks: usize, ) -> ClientResult<usize>
Poll the server to confirm a transaction.
pub fn get_num_blocks_since_signature_confirmation( &self, signature: &Signature, ) -> ClientResult<usize>
pub fn get_latest_blockhash(&self) -> ClientResult<Hash>
pub fn get_latest_blockhash_with_commitment( &self, commitment: CommitmentConfig, ) -> ClientResult<(Hash, u64)>
pub fn is_blockhash_valid( &self, blockhash: &Hash, commitment: CommitmentConfig, ) -> ClientResult<bool>
pub fn get_fee_for_message( &self, message: &impl SerializableMessage, ) -> ClientResult<u64>
pub fn get_new_latest_blockhash(&self, blockhash: &Hash) -> ClientResult<Hash>
pub fn get_transport_stats(&self) -> RpcTransportStats
pub fn get_feature_activation_slot( &self, feature_id: &Pubkey, ) -> ClientResult<Option<Slot>>
pub fn get_inner_client(&self) -> &Arc<RpcClient>
pub fn runtime(&self) -> &Runtime
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RpcClient
impl !RefUnwindSafe for RpcClient
impl Send for RpcClient
impl Sync for RpcClient
impl Unpin for RpcClient
impl !UnwindSafe for RpcClient
Blanket Implementations§
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> 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