Crate sube[−][src]
Expand description
Sube is a lightweight Substrate client with multi-backend support that can use a chain’s type information to auto encode/decode data into human-readable formats like JSON.
Usage
Sube requires one of the metadata versions to be enabled(default: v14
).
You can change it activating the relevant feature.
You will also likely want to activate a backend(default: ws
).
[dependencies]
sube = { version = "0.4", default_features = false, features = ["v13", "http"] }
Creating a client is as simple as instantiating a backend and converting it to a Sube
instance.
// Create an instance of Sube from any of the available backends
let client: Sube<_> = ws::Backend::new_ws2(CHAIN_URL).await?.into();
// With the client you can:
// - Inspect its metadata
let meta = client.metadata().await?;
let system = meta.pallet_by_name("System").unwrap();
assert_eq!(system.index, 0);
// - Query the chain storage with a path-like syntax
let latest_block: JsonValue = client.query("system/number").await?.into();
assert!(
latest_block.as_u64().unwrap() > 0,
"block {} is greater than 0",
latest_block
);
// - Submit a signed extrinsic
// client.submit(SIGNED_EXTRINSIC).await?;
Backend features
- http - Enables a surf based http backend.
- http-web -
Enables surf with its web compatible backend that uses
fetch
under the hood(targetwasm32-unknown-unknown
) - ws - Enables the websocket backend based on tungstenite
- wss -
Same as
ws
and activates the TLS functionality of tungstenite
Re-exports
Modules
Structs
A Dummy backend for offline querying of metadata
Metadata prefixed by a u32 for reserved usage
Represents a key of the blockchain storage in its raw form
Main interface for interacting with the Substrate based blockchain
A container for SCALE encoded data that can serialize types directly with the help of a type registry and without using an intermediate representation.
Enums
Traits
Generic definition of a blockchain backend