Expand description
RPC types and client for interacting with a substrate node.
These is used behind the scenes by various subxt
APIs, but can
also be used directly.
Rpc
is the highest level wrapper, and the one you will run into first. It contains the higher level methods for interacting with a node.RpcClient
is whatRpc
uses to actually talk to a node, offering aRpcClient::request
andRpcClient::subscribe
method to do so.RpcClientT
is the underlying dynamic RPC implementation. This provides the low levelRpcClientT::request_raw
andRpcClientT::subscribe_raw
methods. This can be swapped out for a custom implementation, but by default we’ll rely onjsonrpsee
for this.
Example
Fetching storage keys
use subxt::{ PolkadotConfig, OnlineClient, storage::StorageKey };
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
pub mod polkadot {}
let api = OnlineClient::<PolkadotConfig>::new().await.unwrap();
let key = polkadot::storage()
.xcm_pallet()
.version_notifiers_root()
.to_bytes();
// Fetch up to 10 keys.
let keys = api
.rpc()
.storage_keys_paged(&key, 10, None, None)
.await
.unwrap();
for key in keys.iter() {
println!("Key: 0x{}", hex::encode(&key));
}
Modules
Types sent to/from the Substrate RPC interface.
Macros
Structs
Reference to a range of bytes encompassing a single valid JSON value in the
input data.
Client for substrate rpc interfaces
A concrete wrapper around an
RpcClientT
which exposes the udnerlying interface via some
higher level methods that make it a little easier to work with.This represents the parameters passed to an
RpcClient
, and exists to
enforce that parameters are provided in the correct format.The RPC subscription returned from
RpcClientT
’s subscription
method.A generic RPC Subscription. This implements [
Stream
], and so most of
the functionality you’ll need to interact with it comes from the
[StreamExt
] extension trait.Traits
Any RPC client which implements this can be used in our
super::Rpc
type
to talk to a node.Type Definitions
A boxed future that is returned from the
RpcClientT
methods.The ID associated with the
RpcClientT
’s subscription
.The inner subscription stream returned from our
RpcClientT
’s subscription
method.