chain_subscribeRuntimeVersion - Bittensor RPC Method
Subscribe to runtime version changes on Bittensor via WebSocket. Track runtime upgrades in real time.
Subscribes to runtime version changes over a WebSocket connection. Each time the Bittensor runtime is upgraded, this subscription emits a notification containing the new runtime version details. This allows applications to detect upgrades in real time and update their type registries, metadata, and decoders accordingly.
The initial JSON-RPC response returns a subscription ID. Runtime version objects are delivered afterward as WebSocket notifications on that subscription.
Code Examples
This method requires a WebSocket connection and is not available over HTTP.
WebSocket (wscat)
wscat -c wss://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY \
-x '{
"jsonrpc": "2.0",
"method": "chain_subscribeRuntimeVersion",
"params": [],
"id": 1
}'JavaScript
import { ApiPromise, WsProvider } from '@polkadot/api';
const api = await ApiPromise.create({
provider: new WsProvider('wss://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY')
});
const unsub = await api.rpc.chain.subscribeRuntimeVersion((version) => {
console.log(`Runtime upgrade detected: specVersion=${version.specVersion}`);
console.log(`Transaction version: ${version.transactionVersion}`);
});
// Later: unsub();Use Cases
- Runtime upgrade detection -- React to runtime upgrades by refreshing metadata and type registries so your application can decode new extrinsic and storage formats.
- Indexer maintenance -- Pause or restart indexing pipelines when a runtime upgrade changes storage layouts or extrinsic formats.
- Dashboard alerts -- Display notifications to operators when the Bittensor runtime version changes.
Notes
- The first notification is emitted immediately with the current runtime version.
- Cancel the subscription with
chain_unsubscribeRuntimeVersionwhen no longer needed. - The
transactionVersionfield is critical: if it changes, previously constructed unsigned extrinsics may no longer be valid.
Related Methods
chain_unsubscribeRuntimeVersion-- Cancel this subscriptionstate_subscribeRuntimeVersion-- Equivalent subscription via the state namespacechain_getRuntimeVersion-- One-shot query for current runtime versionstate_getMetadata-- Get the full runtime metadata after detecting an upgrade