* codegen: Update polkadot.rs polkadot commit-hash: d96d3bea85 polkadot tag: v0.9.16-rc2 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Reference key storage api Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Regenerate polkadot.rs with reference api Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Update tests with reference interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Fix polkadot.rs license check Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs with copyright Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "codegen: Update polkadot.rs with copyright" This reverts commit 2970d0573dc0b11d01072b270a525ad497992ddf. Revert "cli: Fix polkadot.rs license check" This reverts commit 6fe8818582ae39669c059c1ed0424b6606620295. * codegen: Implement AccountData trait in the expected order Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Store implementation of StorageEntry Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Generate AccountDefaultData wrapper struct Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Allow `Account` references Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Utilize AccountDefaultData instead of Account Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Update tests to utilize `Account` reference Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Rename AccountDefaultData to AccountOwned Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add comments for wrapper account Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Obtain vector type parameter for TypePath::Type Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use slices instead of `& std::vec` in storage API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Fix documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Remove extra reference Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Add staking example to exercise storage API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Update storage tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix cargo clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Simplify vec_type_param Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Rename staking_details.rs to fetch_staking_details.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Remove dummy variable Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Update polkadot version Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Apply rust-fmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Regenerate polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Remove comment Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
subxt ·

A library to submit extrinsics to a substrate node via RPC.
⚠️ Health Warning ⚠️ considered alpha after recent changes, API still subject to change
See https://github.com/paritytech/subxt/issues/309 for an overview of outstanding issues.
Usage
Take a look in the examples folder for various subxt usage examples.
Downloading metadata from a Substrate node
Use the subxt-cli tool to download the metadata for your target runtime from a node.
- Install:
cargo install subxt-cli
- Save the encoded metadata to a file:
subxt metadata -f bytes > metadata.scale
This defaults to querying the metadata of a locally running node on the default http://localhost:9933/. If querying
a different node then the metadata command accepts a --url argument.
Generating the runtime API from the downloaded metadata
Declare a module and decorate it with the subxt attribute which points at the downloaded metadata for the
target runtime:
#[subxt::subxt(runtime_metadata_path = "metadata.scale")]
pub mod node_runtime { }
Important: runtime_metadata_path resolves to a path relative to the directory where your crate's Cargo.toml
resides (CARGO_MANIFEST_DIR), not relative to the source file.
Initializing the API client
API is still a work in progress. See examples for the current usage.
Querying Storage
API is still a work in progress. See tests for the current usage.
Submitting Extrinsics
API is still a work in progress. See examples for the current usage.
Integration Testing
Most tests require a running substrate node to communicate with. This is done by spawning an instance of the
substrate node per test. It requires an executable binary substrate at polkadot-v0.9.10 on your path.
This can be installed from source via cargo:
cargo install --git https://github.com/paritytech/substrate node-cli --tag=polkadot-v0.9.10 --force
Real world usage
Please add your project to this list via a PR.
- cargo-contract CLI for interacting with Wasm smart contracts.
- xcm-cli CLI for submitting XCM messages.
- phala-pherry The relayer between Phala blockchain and the off-chain Secure workers.
- crunch CLI to claim staking rewards in batch every Era or X hours for substrate-based chains.
- interbtc-clients Client implementations for the interBTC parachain; notably the Vault / Relayer and Oracle.
Alternatives
substrate-api-client provides similar functionality.