state_subscribeRuntimeVersion
Description
Subscribe to storage or runtime version updates over WebSocket. Drive live UIs that react to on‑chain changes.
Subscribes to runtime version updates. Requires WebSocket.
Code Examples
- cURL
- JavaScript (polkadot.js)
Not supported over HTTP; use WebSocket.
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((v) => {
console.log('runtime version:', v.toHuman());
});
// Later: await unsub();