Substrate: How to install subkey tool

Install Substrate subkey command line tool

Subkey is a command-line utility for the Substrate framework used to create and manage keys, sign and verify signatures and interact with the keystore file. In this article, we will demonstrate how to build a subkey tool from the source code and then install it so that it is available anywhere in the system.

Note: The subkey was built using the 3.0.0/0.9.0 - Apollo 14 release on Ubuntu server 18.04.

It is assumed that you already have the Rust toolchain with the nightly release and nightly WebAssembly (wasm) targets installed on your system. These are needed when working with the substrate framework. Check this page on how to install it for Linux.

Step 1 - Download the subkey source from GitHub

The source code for the subkey tool can be found in the official Substrate repository.

So let's clone this repository by using the following command:

git clone

Within the Substrate repository source code, we are only interested in the subkey. In the next step, we will build and install only this tool.

Step 2 - Build and install the package

First, we need to go to the root of the substrate directory that we just cloned:

cd substrate

Instead of just building the package, we want to install it in the /root/.cargo/bin/ directory so it is available anywhere on the system.

We can do both, build and install by running the following command:

cargo +nightly install subkey --path bin/utils/subkey

This will build the subkey package located in the substrate repository at bin/utils/subkey using nightly toolchain. The build might take a few minutes to complete.

Note: To build the package without installing it to the /root/.cargo/bin/ directory, use the "cargo +nightly build --package subkey --release" command instead.

Step 3 - Verify that the subkey installed successfully

The subkey binary is located in the /target/release/ of the substrate directory, but because we used cargo install command, it also copied the binary inside the /root/.cargo/bin/ directory, so it should be available anywhere on the system.

We might need to start a new shell session for subkey to be available on any path, or we can use the following command to make it available immediately in the current shell session:

source ~/.bashrc

We can confirm that the system finds the subkey tool by running the subkey from the current directory:

subkey --version

Possible errors during the subkey build

One error I encountered during the subkey build was related to the libp2p-core package:

error: failed to run custom build command for `libp2p-core v0.38.0`

This was solved by installing the protobuf-compiler package:

sudo apt install protobuf-compiler


A subkey is a command-line tool for the Substrate framework used in the generation and management of keys and signatures. It is located in the Substrate repository, so we first cloned this repository, then used cargo install to build the subkey package and finally installed it in the /root/.cargo/bin/ directory, so that the subkey utility is available anywhere in the system.


Write a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.