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.
Rpcis the highest level wrapper, and the one you will run into first. It contains the higher level methods for interacting with a node.RpcClientis whatRpcuses to actually talk to a node, offering aRpcClient::requestandRpcClient::subscribemethod to do so.RpcClientTis the underlying dynamic RPC implementation. This provides the low levelRpcClientT::request_rawandRpcClientT::subscribe_rawmethods. This can be swapped out for a custom implementation, but by default we’ll rely onjsonrpseefor 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.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.