gear-subxt 0.29.0

Submit extrinsics (transactions) to a substrate node via RPC
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use subxt::{OnlineClient, PolkadotConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a client to use:
    let api = OnlineClient::<PolkadotConfig>::new().await?;

    // A dynamic query to obtain some contant:
    let constant_query = subxt::dynamic::constant("System", "BlockLength");

    // Obtain the value:
    let value = api.constants().at(&constant_query)?;

    println!("Constant bytes: {:?}", value.encoded());
    println!("Constant value: {}", value.to_value()?);
    Ok(())
}