I am building a somewhat generic client for Substrate-based chains in Rust using the subxt
crate. To learn about runtime calls, my goal was to call the core.version
runtime API directly using the RPC endpoint state_call
.
Internally subxt
uses a special RPC endpoint state_getRuntimeVersion
, but that just gets redirected to the runtime at the specific block anyways:
/// Fetch the runtime version
pub async fn runtime_version(
&self,
at: Option<T::Hash>,
) -> Result<RuntimeVersion, BasicError> {
let params = rpc_params![at];
let version = self
.client
.request("state_getRuntimeVersion", params)
.await?;
Ok(version)
}
This was my try to make the runtime call directly:
let version: subxt::rpc::RuntimeVersion = rpc_client
.rpc()
.client
.request("state_call", rpc_params!["core.version", ""])
.await
.unwrap();
But it just errs out with Exported method core.version is not found
. How can I make this call work?
Core_version
. Still, decoding theRuntimeVersion
from the returned JSON string and encoding the call parameters and the blockhash still seems to be missing an example.