Files
pezkuwi-subxt/subxt/examples/constants_static.rs
T
James Wilson e40a8629e2 move examples to main repo so we can include_str them for publishing (#993)
* move exampels to main repo so we can include_str them for publishing

* update CI to not break examples
2023-06-01 14:27:12 +01:00

20 lines
564 B
Rust

use subxt::{OnlineClient, PolkadotConfig};
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client to use:
let api = OnlineClient::<PolkadotConfig>::new().await?;
// A query to obtain some contant:
let constant_query = polkadot::constants().system().block_length();
// Obtain the value:
let value = api.constants().at(&constant_query)?;
println!("Block length: {value:?}");
Ok(())
}