state_getRuntimeVersion - JSON-RPC Method
Description
Returns the active runtime metadata versions for an Enjin Matrix node, including the specVersion
and transactionVersion
. These values are essential when caching metadata, selecting type bundles, or ensuring extrinsic encoding compatibility after runtime upgrades.
Parameters
No parameters are required.
Returns
Field | Type | Description |
---|---|---|
specName | string | Runtime identifier (matrix-enjin ) |
implName | string | Implementation identifier |
specVersion | number | Runtime specification version (increments on upgrades) |
implVersion | number | Implementation version |
transactionVersion | number | Transaction encoding version |
apis | array | RPC API versions exposed by the runtime |
Request Example
{
"jsonrpc": "2.0",
"method": "state_getRuntimeVersion",
"params": [],
"id": 1
}
Response Example
{
"jsonrpc": "2.0",
"result": {
"specName": "matrix-enjin",
"implName": "matrix-enjin",
"authoringVersion": 0,
"specVersion": 1022,
"implVersion": 0,
"apis": [
["0xfbc577b9d747efd6", 1],
["0xdf6acb689907609b", 5],
["0x37e397fc7c91f5e4", 2],
["0x40fe3ad401f8959a", 6],
["0xd7bdd8a272ca0d65", 1],
["0xd2bc9897eed08f15", 3],
["0xf78b278be53f454c", 2],
["0xab3c0572291feb8b", 1],
["0xdd718d5cc53262d4", 1],
["0xea93e3f16f3d6962", 2],
["0xbc9d89904f5b923f", 1],
["0x37c8bb1350a9a2a8", 4],
["0xf3ff14d5ab527059", 3],
["0x37242681f96a7abd", 1],
["0xc90bb9b17b276147", 1]
],
"transactionVersion": 11,
"stateVersion": 0
},
"id": 1
}
Code Examples
cURL
curl https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "state_getRuntimeVersion",
"params": [],
"id": 1
}'
JavaScript (Polkadot.js)
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
const runtime = await api.rpc.state.getRuntimeVersion();
console.log(`specVersion=${runtime.specVersion}, transactionVersion=${runtime.transactionVersion}`);
Rust (subxt)
use subxt::rpc::RpcClient;
use subxt::OnlineClient;
use subxt::PolkadotConfig;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = OnlineClient::<PolkadotConfig>::from_url(
"wss://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY"
).await?;
let runtime = api.rpc().runtime_version(None).await?;
println!("specVersion={} txVersion={}", runtime.spec_version, runtime.transaction_version);
Ok(())
}
Upgrade Playbook
- Cache metadata keyed by
specVersion
and refresh whenever this value increases. - Regenerate type bundles or schema definitions after runtime upgrades to account for breaking changes.
- Monitor
transactionVersion
to validate that transaction payload formats are still supported by your SDK version.