state_getRuntimeVersion
Description#
Returns the current runtime version, including specVersion and transactionVersion. Applications must monitor these values to refresh metadata and rebuild extrinsics after upgrades.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
blockHash | string | No | Block hash to query historical versions |
Returns#
| Field | Type | Description |
|---|---|---|
specName | string | Runtime specification name |
implName | string | Implementation name |
authoringVersion | number | Authoring version |
specVersion | number | Runtime spec version |
implVersion | number | Implementation version |
transactionVersion | number | Transaction version |
apis | array | Supported runtime APIs and versions |
Request Example#
{
"jsonrpc": "2.0",
"method": "state_getRuntimeVersion",
"params": [],
"id": 1
}
Response Example#
{
"jsonrpc": "2.0",
"result": {
"specName": "bifrost_polkadot",
"implName": "bifrost-node",
"authoringVersion": 1,
"specVersion": 21001,
"implVersion": 0,
"transactionVersion": 1,
"apis": [
["0xdf6acb689907609b", 4],
["0x37e397fc7c91f5e4", 2],
["0xd2bc9897eed08f15", 3]
]
},
"id": 1
}
Code Examples#
- Python
- JavaScript
version = substrate.rpc_request('state_getRuntimeVersion', [])["result"]
print(version['specName'], version['specVersion'])
const runtime = await api.rpc.state.getRuntimeVersion();
console.log(`Spec ${runtime.specVersion.toNumber()} txVersion ${runtime.transactionVersion.toNumber()}`);
Tips#
- Trigger metadata refresh whenever
specVersionchanges. - If
transactionVersionincrements, rebuild and re-sign extrinsics; old payloads will be rejected with1010: Invalid Transaction.