# chain_subscribeRuntimeVersion - Bittensor RPC Method

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.

## Request Parameters

This method accepts no parameters.

## Request Example

```bash
wscat -c wss://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY \
  -x '{
    "jsonrpc": "2.0",
    "method": "chain_subscribeRuntimeVersion",
    "params": [],
    "id": 1
  }'
```

## Response Fields

- `specName` (`string, required`): Runtime specification name (e.g. `"node-subtensor"`)
- `implName` (`string, required`): Implementation name
- `specVersion` (`number, required`): Specification version number; increments with each runtime upgrade
- `implVersion` (`number, required`): Implementation version
- `transactionVersion` (`number, required`): Transaction format version; changes indicate breaking extrinsic format changes
- `apis` (`array, required`): List of supported runtime API versions

## Successful Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "subscription_id_here"
}
```

## Code Examples

> This method requires a WebSocket connection and is not available over HTTP.

### WebSocket (wscat)

```bash
wscat -c wss://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY \
  -x '{
    "jsonrpc": "2.0",
    "method": "chain_subscribeRuntimeVersion",
    "params": [],
    "id": 1
  }'
```

### JavaScript

```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_unsubscribeRuntimeVersion` when no longer needed.
- The `transactionVersion` field is critical: if it changes, previously constructed unsigned extrinsics may no longer be valid.

## Related Methods

- [`chain_unsubscribeRuntimeVersion`](https://www.dwellir.com/docs/bittensor/chain_unsubscribeRuntimeVersion) -- Cancel this subscription
- [`state_subscribeRuntimeVersion`](https://www.dwellir.com/docs/bittensor/state_subscribeRuntimeVersion) -- Equivalent subscription via the state namespace
- [`chain_getRuntimeVersion`](https://www.dwellir.com/docs/bittensor/chain_getRuntimeVersion) -- One-shot query for current runtime version
- [`state_getMetadata`](https://www.dwellir.com/docs/bittensor/state_getMetadata) -- Get the full runtime metadata after detecting an upgrade
