Files
pezkuwi-subxt/examples/examples/rpc_call.rs
T
Alexandru Vasile f48a5df2ca Fix history_depth testing (#662)
* testing/staking: `history_depth` storage is now a constant

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* artifacts: Update metadata from `9ffe6e9e3da`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* testing: Update `polkadot.rs` from `9ffe6e9e3da`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* examples: Update comment wrt polkadot version

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Fix clippy

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
2022-09-22 16:02:30 +01:00

36 lines
994 B
Rust

// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
//! To run this example, a local polkadot node should be running. Example verified against polkadot v0.9.28-9ffe6e9e3da.
//!
//! E.g.
//! ```bash
//! curl "https://github.com/paritytech/polkadot/releases/download/v0.9.28/polkadot" --output /usr/local/bin/polkadot --location
//! polkadot --dev --tmp
//! ```
use subxt::{
OnlineClient,
PolkadotConfig,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt::init();
let api = OnlineClient::<PolkadotConfig>::new().await?;
let block_number = 1u32;
let block_hash = api.rpc().block_hash(Some(block_number.into())).await?;
if let Some(hash) = block_hash {
println!("Block hash for block number {block_number}: {hash}");
} else {
println!("Block number {block_number} not found.");
}
Ok(())
}