state_subscribeRuntimeVersion - JSON-RPC M...
Monitor Bittensor runtime updates. Track protocol upgrades.
Subscribes to runtime version updates over a WebSocket connection. Use it to detect Bittensor runtime upgrades so your indexers, signers, and type registries can refresh before decoding new blocks or extrinsics.
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": "state_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.state.subscribeRuntimeVersion((version) => {
console.log(`Runtime upgrade detected: specVersion=${version.specVersion}`);
console.log(`Transaction version: ${version.transactionVersion}`);
});
// Later: unsub();Use Cases
- Metadata refresh -- Detect runtime upgrades and reload metadata before decoding new blocks or extrinsics.
- Signer safety -- Watch
transactionVersionchanges that can invalidate previously prepared unsigned transactions. - Operational alerting -- Notify operators or dashboards when Bittensor upgrades on-chain logic.
Notes
- The first notification typically arrives immediately with the current runtime version.
- Cancel the subscription with
state_unsubscribeRuntimeVersionwhen you no longer need updates. - This subscription is WebSocket-only.
Related Methods
state_unsubscribeRuntimeVersion-- Cancel this subscriptionchain_subscribeRuntimeVersion-- Equivalent runtime-version subscription via the chain namespacechain_getRuntimeVersion-- One-shot runtime version query