[0.41.0] - 2025-03-10
This release makes two main changes:
Add subxt-rpcs
crate.
Previously, if you wanted to make raw RPC calls but weren't otherwise interested in using the higher level Subxt interface, you still needed to include the entire Subxt crate.
Now, one can depend on subxt-rpcs
directly. This crate implements the new RPC-V2 chainHead
/transaction
endpoints as well as the currently unstable archive
endpoints. it also implements various legacy endpoints that Subxt uses as a fallback to the modern ones. It also provides several feature gated clients for interacting with them:
- jsonrpsee: A
jsonrpsee
based RPC client for connecting to individual RPC nodes. - unstable-light-client: A Smoldot based light client which connects to multiple nodes in chains via p2p and verifies everything handed back, removing the need to trust any individual nodes.
- reconnecting-rpc-client: Another
jsonrpsee
based client which handles reconnecting automatically in the event of network issues. - mock-rpc-client: A mock RPC client that can be used in tests.
Custom clients can be implemented if preferred.
Example usage via jsonrpsee
feature:
use subxt_rpcs::{RpcClient, ChainHeadRpcMethods};
// Connect to a local node:
let client = RpcClient::("ws://127.0.0.1:9944").await?;
// Use chainHead/archive V2 methods:
let methods = ChainHeadRpcMethods::new(client);
// Call some RPC methods (in this case a subscription):
let mut follow_subscription = methods.chainhead_v1_follow(false).await.unwrap();
while let Some(follow_event) = follow_subscription.next().await {
// do something with events..
}
Support creating V5 transactions.
Subxt has supported decoding V5 transactions from blocks since 0.38.0, but now it also supports constructing V5 transactions where allowed. Some naming changes have also taken place to align with the Substrate terminology now around transactions (see #1931 for more!).
The main changes here are:
subxt_core
now contains versioned methods for creating each of the possible types of transaction (V4 unsigned, V4 signed, V5 "bare" or V5 "general"), enabling the APIs to be tailored for each case.subxt
exposes higher level wrappers these (ieapi.tx().create_v4_unsigned(..)
,api.tx().create_v5_bare(..)
), but also continues to expose the same standard APIs for creating transactions which will, under the hood, decide what to create based on the chain we're connected to.- APIs like
sign_and_submit
now take aT::AccountId
rather than aT::Address
since it was found to not be useful to provide the latter, and V5 transactions only expect anT::AccountId
. - Signed Extensions are now referred to as Transaction Extensions, and we've tweaked the interface around how these work slightly to accomodate the fact that in V5 transactions, the signature is passed into a transaction extension where applicable (
VerifySignature
). - As a side effect, it's simpler to set mortality on transactions; no more block hash needs to be provided; only the number of blocks you would like a transaction to live for.
A full list of the relevant changes is as follows:
Added
- Support constructing and submitting V5 transactions (#1931)
- Add archive RPCs to subxt-rpcs (#1940)
- Document generating interface from Runtime WASM and change feature to
runtime-wasm-path
(#1936) - Split RPCs into a separate crate (#1910)