mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-22 18:28:01 +00:00
1e111ea9db
* Move Extrinsic decoding things to subxt_core and various tidy-ups * A couple more fixes and fmt * first pass moving tx logic to subxt_core * cargo fmt * fix wasm example * clippy * more clippy * WIP Adding examples and such * Move storage functionality more fully to subxt_core and nice examples for storage and txs * Add example for events * consistify how addresses/payloads are exposed in subxt-core and add runtime API fns * Add runtime API core example * fmt * remove scale-info patch * Add a little to the top level docs * swap args around * clippy * cargo fmt and fix wasm-example * doc fixes * no-std-ise new subxt-core additions * alloc, not core * more no-std fixes * A couple more fixes * Add back extrinsic decode test
32 lines
1.2 KiB
Rust
32 lines
1.2 KiB
Rust
#![allow(missing_docs)]
|
|
use subxt::{OnlineClient, PolkadotConfig};
|
|
use subxt_signer::sr25519::dev;
|
|
|
|
// Generate an interface that we can use from the node's metadata.
|
|
#[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 new API client, configured to talk to Polkadot nodes.
|
|
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
|
|
|
// Build a storage query to access account information.
|
|
let account = dev::alice().public_key().into();
|
|
let storage_query = polkadot::storage().system().account(&account);
|
|
|
|
// Use that query to `fetch` a result. This returns an `Option<_>`, which will be
|
|
// `None` if no value exists at the given address. You can also use `fetch_default`
|
|
// where applicable, which will return the default value if none exists.
|
|
let result = api
|
|
.storage()
|
|
.at_latest()
|
|
.await?
|
|
.fetch_raw(subxt_core::storage::get_address_bytes(&storage_query, &api.metadata()).unwrap())
|
|
.await?;
|
|
|
|
let v = hex::encode(result.unwrap());
|
|
println!("Alice: {v}");
|
|
Ok(())
|
|
}
|