Module subxt::rpc

source ·
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.

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

Create some RpcParams to pass to our RpcClient. RpcParams simply enforces that parameters handed to our RpcClient methods are the correct shape.

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.