Verify WASM
Expose the features of the runtime for any Substrate chain.
The subwasm tool provides a way to expose the features of the runtime for any Substrate chain. This guide shows you how to use Subwasm to do the following:
Get a snapshot of the modules in a runtime.
Expose verifiable historical information of a chain's runtime for front end applications.
Check for changes between two runtimes using a diff.
Before you begin
Make sure you have the following:
The latest release of Subwasm installed.
A chain running locally that is executing the runtime you wish to examine.
JQ installed in your environment to enable filtering the metadata.
Get information about a runtime of a local chain
Launch a local node from inside your chain's directory. This example launches a node template in dev mode.
In a new terminal, create a temporary folder called
TempWasms
.Inside the new folder, use Subwasm to get and save the Wasm of your local chain.
The
-o
flag will save the Wasm file tomychain.wasm
.Run the following command to save your chain's metadata to a JSON file:
You can use JQ to filter the metadata details from the
subwasm --json meta mychain.wasm
command. This example ignores all documentation metadata. For information about the metadata fields that a Substrate chain exposes, see the documentation on Substrate Metadata.After you have saved the metadata in a JSON file, you can use it in a front-end application.
Compare two different runtimes of a live chain
You can also use Subwasm to compare the runtimes of a chain at different blocks. Subwasm uses a function that takes the URL of common Substrate chains such as Polkadot, Kusama and Westend, and returns the node's endpoint. The following example compares the Polkadot runtime at block 500,000 with its latest runtime.
Go to a block explorer and retrieve the block hash for the runtime you want to compare against.
For example, go to PolkadotJS Apps and retrieve the block hash at block 500000.
0xfdeab19649426aadbdab046c9b5dac0a5b0c850b8fd0927e3b4e6c896d5fb0b7
Save the Wasm blob of a previous state.
Get the latest Wasm blob of the runtime.
Compare the two runtimes and put the output into a JSON file.
Examples
There are many use cases for subwasm
as outlined above. Some additional examples include:
Compressing and decompressing a Wasm file.
Inspecting a Wasm file to verify a runtime upgrade in governance.
Last updated