Is possible to extract the runtime version from the WASM file?

Sometimes, I want to verify the WASM file's content locally.

1 Answer 1


tldr: Yes it is possible :)

There is a tool (and a bunch of crates) that actually aims at getting as many info as possible from a substrate wasm blob without requiring any node, it is called subwasm: https://github.com/chevdor/subwasm

IMPORTANT: Make sure to install from the repo and not from crates.io. See repo for details.

If you don't have a runtime at hand, subwasm can help you fetch one quickly:

subwasm get --chain westend -o /tmp/runtime.wasm

Assuming you have a runtime as /tmp/runtime.wasm, you can use either the info or the (new) version command, for instance:

subwasm info /tmp/westend.wasm --json | jq -r .core_version.specVersion

It will return 9260 (currently). This call does NOT require a node and work totally offline.

subwasm can get you more information, the same way the Polkadot release notes show runtimes, for instance:

subwasm info /tmp/runtime.wasm

will output:

Running subwasm v0.18.0
🏋️  Runtime size:                1.138 MB (1,193,760 bytes)
🗜  Compressed:                  Yes, 80.61%
✨ Reserved meta:                OK - [6D, 65, 74, 61]
🎁 Metadata version:             V14
🔥 Core version:                 westend-9260 (parity-westend-0.tx11.au2)
🗳️  system.setCode hash:         0xb98632189a72582b350912cd4b70fe393fe71140c1f7ed7a95082dd95a3db8ae
🗳️  authorizeUpgrade hash:       0x1dd000c1b9c9d2f1df4f5fde6ea6965b32b1aba0b207e8da8e93773123c3d49c
#️⃣  Blake2-256 hash:             0x6190bd415a14354629aee74dbb1a0c907ea800acd2a0842d8184b86185e4dde3
📦 IPFS:                         https://www.ipfs.io/ipfs/QmXW<...>H8SwGFGWEyJ4

If you are more focused on the version itself, you can use the (fairly recent) version command:

subwasm version /tmp/westend.wasm 

which will output:

Running subwasm v0.18.0
specifications : westend v9260
implementation : parity-westend v0
transaction    : v11
authoring      : v2

Most commands output text by default but support the --json flag as well.

Most commands work offline as shown above (and that's the main purpose of subwasm) but for convenience, subwasm can also fetch the runtime from a node, this is what happened with you call subwam info --chain westend, in that case, subwasm does not query the remote node for the data via RPC, instead it only fetches (via RPC) the wasm blob, decodes it and calls the runtime direclty and locally.

So using the --chain flag is like doing a get first to get the runtime locally.

NOTE: if you want to know more about the content of the runtime, you can check out the meta (alias for metadata) command as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.