:toc: :sectnums: :sectanchors:

:cmd: substrate-runtime-hasher :proj: pass:q[substrate-runtime-hasher] :version: v0.2.6 :srtool: pass:q[https://gitlab.com/chevdor/srtool[srtool]]

= {proj}

When a candidate runtime is submitted to a Substrate-based chain such as Polkadot or Substrate, this WASM blob is hashed. The proposal hash that can be seen is actually the prefixed and hashed runtime. This utility does the same and allows calculating the proposal hash of a new runtime off-chain.

You do not need a node, nor even an internet connection to use this utility.

The rustdoc can be found https://chevdor.gitlab.io/substrate-runtime-hasher/substrateruntimehasher[here].

This is the documentation for {cmd} {version}.

== Install

[source,bash,subs="attributes+"] cargo install --git https://gitlab.com/chevdor/substrate-runtime-hasher.git --tag {version}

[subs="attributes"] WARNING: Installing the version from master is not recommended for production: do NOT omit the --tag {version} in the previous command.

== Usage

=== Sample run

In the following examples, the path of the WASM file will be stored into a variables called WASM.

You may set it with:

export WASM=/home/foobar/kusama/target/srtool/release/wbuild/kusama-runtime/kusama_runtime.compact.wasm

.Build your runtime... or let {srtool} do it [source,bash,subs="attributes+"] cd # build the runtime (you could use srtool)

.Invoke {proj}
[source,bash,subs="attributes+"] {cmd} $WASM 0x5931690e71e9d3d9f04a43d8c15e45e0968e563858dd87ad6485b2368a286a8f

NOTE: If you are using {srtool}, it will do everything for you. The default location for the WASM will be inside your repo in $WASM (for instance, for kusama).

=== Unix pipes & input redirection

Since v0.2.1, you can also use Unix pipes:

.Piping into {cmd} [source,bash,subs="attributes+"] cat $WASM | {cmd} 0x5931690e71e9d3d9f04a43d8c15e45e0968e563858dd87ad6485b2368a286a8f

.Input redirection [source,bash,subs="attributes+"] {cmd} < $WASM 0x5931690e71e9d3d9f04a43d8c15e45e0968e563858dd87ad6485b2368a286a8f

WARNING: If you are using commands such as echo make sure to NOT send an extra newline. For instance echo "123" | {cmd} will not hash 123 but 123<cr>. In that case, you probably want to use echo -n "123" | {cmd}

=== Help! [source,bash,subs="attributes+"] {cmd} --help

You should see an output similar to:

[source,bash,subs="attributes+"]

{cmd} 0.2.1
Wilfried Kopp <chevdor@gmail.com>
Hash data the same way Substrate-based chains such as Kusama or Polkadot. 
This gives a hash matching proposal hashes onchain.

USAGE:
    {cmd} [FLAGS] [INPUT]

FLAGS:
    -h, --help       Prints help information
    -v               Sets the level of verbosity
    -V, --version    Prints version information

ARGS:

Sets the input file to use. Alternatively, you may pipe .

== References

== License


include::LICENSE[]