06ab693b4c
- Update copyright from 'Parity Technologies (UK) Ltd.' to 'Dijital Kurdistan Tech Institute' - Update year to 2026 - Mark doc tests with relative metadata paths as 'ignore' to fix workspace-level doc tests - Affected files: runtime_apis.rs, storage.rs, constants.rs, transactions.rs, codegen.rs The doc tests use relative paths like '../artifacts/*.scale' which only work when testing the crate directly (-p pezkuwi-subxt), not during workspace-level tests. The examples/ directory contains the actual runnable test code.
51 lines
2.2 KiB
Rust
51 lines
2.2 KiB
Rust
// Copyright 2019-2026 Dijital Kurdistan Tech Institute
|
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
|
// see LICENSE for license details.
|
|
|
|
//! # Light Client
|
|
//!
|
|
//! The light client based interface uses _Smoldot_ to connect to a _chain_, rather than an
|
|
//! individual node. This means that you don't have to trust a specific node when interacting with
|
|
//! some chain.
|
|
//!
|
|
//! This feature is currently unstable. Use the `unstable-light-client` feature flag to enable it.
|
|
//! To use this in WASM environments, enable the `web` feature flag and disable the "native" one.
|
|
//!
|
|
//! To connect to a blockchain network, the Light Client requires a trusted sync state of the
|
|
//! network, known as a _chain spec_. One way to obtain this is by making a `sync_state_genSyncSpec`
|
|
//! RPC call to a trusted node belonging to the chain that you wish to interact with.
|
|
//!
|
|
//! Subxt exposes a utility method to obtain the chain spec:
|
|
//! [`crate::utils::fetch_chainspec_from_rpc_node()`]. Alternately, you can manually make an RPC
|
|
//! call to `sync_state_genSyncSpec` like do (assuming a node running locally on port 9933):
|
|
//!
|
|
//! ```bash
|
|
//! curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "sync_state_genSyncSpec", "params":[true]}' http://localhost:9933/ | jq .result > chain_spec.json
|
|
//! ```
|
|
//!
|
|
//! ## Examples
|
|
//!
|
|
//! ### Basic Example
|
|
//!
|
|
//! This basic example uses some already-known chain specs to connect to a relay chain and parachain
|
|
//! and stream information about their finalized blocks:
|
|
//!
|
|
//! ```rust,ignore
|
|
#![doc = include_str!("../../../examples/light_client_basic.rs")]
|
|
//! ```
|
|
//!
|
|
//! ### Connecting to a local node
|
|
//!
|
|
//! This example connects to a local chain and submits a transaction. To run this, you first need
|
|
//! to have a local pezkuwi node running using the following command:
|
|
//! ```text
|
|
//! pezkuwi --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001
|
|
//! ```
|
|
//!
|
|
//! Then, the following code will download a chain spec from this local node, alter the bootnodes
|
|
//! to point only to the local node, and then submit a transaction through it.
|
|
//! ```rust,ignore
|
|
#![doc = include_str!("../../../examples/light_client_local_node.rs")]
|
|
//! ```
|
|
//!
|