Answer for stack question 8663

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-05-29 14:04:15 +03:00
parent b88cd0a3fc
commit 6c4c58e004
2 changed files with 26 additions and 0 deletions
Binary file not shown.
+26
View File
@@ -0,0 +1,26 @@
use subxt::{OnlineClient, PolkadotConfig};
// Generate an interface that we can use from the node's metadata.
#[subxt::subxt(runtime_metadata_path = "../artifacts/test_metadata.scale")]
pub mod polkadot {}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new API client, configured to talk to Polkadot nodes.
let api = OnlineClient::<PolkadotConfig>::from_url("wss://rpc.polkadot.io:443").await?;
// Build the query.
let storage_query = polkadot::storage().paras().parachains();
// Fetch the result.
let result = api
.storage()
.at_latest()
.await?
.fetch(&storage_query)
.await?;
println!("polkadot::storage().paras().parachains(): {result:?}");
Ok(())
}