Crate pezkuwi_subxt

Crate pezkuwi_subxt 

Source
Expand description

Subxt is a library for interacting with Bizinikiwi based nodes. Using it looks something like this:

#![allow(missing_docs)]
use pezkuwi_subxt::{OnlineClient, PezkuwiConfig};
use pezkuwi_subxt_signer::sr25519::dev;

// Generate an interface that we can use from the node's metadata.
#[pezkuwi_subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod pezkuwi {}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
	// Create a new API client, configured to talk to Pezkuwi nodes.
	let api = OnlineClient::<PezkuwiConfig>::new().await?;

	// Build a balance transfer extrinsic.
	let dest = pezkuwi::runtime_types::sp_runtime::multiaddress::MultiAddress::Id(
		pezkuwi::runtime_types::sp_core::crypto::AccountId32(dev::bob().public_key().0),
	);
	let balance_transfer_tx = pezkuwi::tx().balances().transfer_allow_death(dest, 10_000);

	// Submit the balance transfer extrinsic from Alice, and wait for it to be successful
	// and in a finalized block. We get back the extrinsic events if all is well.
	let from = dev::alice();
	let events = api
		.tx()
		.sign_and_submit_then_watch_default(&balance_transfer_tx, &from)
		.await?
		.wait_for_finalized_success()
		.await?;

	// Find a Transfer event and print it.
	let transfer_event = events.find_first::<pezkuwi::balances::events::Transfer>()?;
	if let Some(event) = transfer_event {
		println!("Balance transfer success: {event:?}");
	}

	Ok(())
}

Take a look at the Subxt guide to learn more about how to use Subxt.

Re-exports§

pub use crate::client::OfflineClient;
pub use crate::client::OnlineClient;
pub use crate::error::Error;
pub use pezkuwi_subxt_lightclient as lightclient;unstable-light-client

Modules§

backend
This module exposes a backend trait for Subxt which allows us to get and set the necessary information (probably from a JSON-RPC API, but that’s up to the implementation).
blocks
This module exposes the necessary functionality for working with events.
book
The Subxt Guide
client
This module provides two clients that can be used to work with transactions, storage and events. The OfflineClient works entirely offline and can be passed to any function that doesn’t require network access. The OnlineClient requires network access.
config
This module provides a Config type, which is used to define various types that are important in order to speak to a particular chain. BizinikiwConfig provides a default set of these types suitable for the default Bizinikiwi node implementation, and PezkuwiConfig for a Pezkuwi node.
constants
Types associated with accessing constants.
custom_values
Types associated with accessing custom types
dynamic
Submit dynamic transactions.
error
Types representing the errors that can be returned.
events
This module exposes the types and such necessary for working with events. The two main entry points into events are crate::OnlineClient::events() and calls like crate::tx::TxProgress::wait_for_finalized_success().
ext
Re-export external crates that are made use of in the subxt API.
metadata
Types representing the metadata obtained from a node.
runtime_api
Types associated with executing runtime API calls.
storage
Types associated with accessing and working with storage items.
tx
Create and submit extrinsics.
utils
Miscellaneous utility helpers.
view_functions
Types associated with executing View Function calls.

Structs§

Metadata
Node metadata. This can be constructed by providing some compatible frame_metadata which is then decoded into this. We aim to preserve all of the existing information in the incoming metadata while optimizing the format a little for Subxt’s use cases.

Enums§

BizinikiwConfig
Default set of commonly used types by Bizinikiwi runtimes.
PezkuwiConfig
Default set of commonly used types by Pezkuwi nodes.

Traits§

Config
Runtime types.

Attribute Macros§

subxt
Generate a strongly typed API for interacting with a Bizinikiwi runtime from its metadata of WASM.