diff --git a/artifacts/test_metadata.scale b/artifacts/test_metadata.scale new file mode 100644 index 0000000000..adb86a5f8e Binary files /dev/null and b/artifacts/test_metadata.scale differ diff --git a/examples/examples/stack_8663.rs b/examples/examples/stack_8663.rs new file mode 100644 index 0000000000..fc04ef1e18 --- /dev/null +++ b/examples/examples/stack_8663.rs @@ -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> { + // Create a new API client, configured to talk to Polkadot nodes. + let api = OnlineClient::::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(()) +}