# Running the node

## The distribution package

The distribution  package includes:

* `humanode-peer` - the [main binary](/docs/node/cli.md) to launch the humanode peer.
* `chain-spec` - the collection of information that describes a Substrate-based blockchain network. Check [the substrate source](https://docs.substrate.io/build/chain-spec/) to get more details.
* `ngrok-wrapper` - a tool that enables a proper ports forwarding in NAT (and `ngrok`-like tunnel) to connect to your node's RPC endpoint from a handheld device (i.e. phone).

## Running the peer

{% hint style="info" %}
Note that when switching from the Launcher deployment to the manual deployment inplace you might have to adjust the commands to use the same workspace layout as the Launcher.

In order to do that, add the `--base-path "$HOME/.humanode/workspaces/default/substrate-data"` option to the commands below.
{% endhint %}

### Bioauth key generation

Generate your bioauth key, the one that is used for enrolment and authentication.

```shell-session
$ humanode-peer key generate
Secret phrase:       drop find ginger chief worry trial electric sense long deer lock north
  Network ID:        substrate
  Secret seed:       0xd35f23dd8c1672467c57a55dcf8d6761dd2238fec489e1c8cf90c437b18aefce
  Public key (hex):  0xf8eb7c948e3889c3149296e5a25b25f98f4814e781968cf5876f8cab474d480f
  Account ID:        0xf8eb7c948e3889c3149296e5a25b25f98f4814e781968cf5876f8cab474d480f
  Public key (SS58): 5Hh5gnML29ZkoSgkrYCeMw8BC4tu5R6q7NgRWfXZnp1NZei3
  SS58 Address:      5Hh5gnML29ZkoSgkrYCeMw8BC4tu5R6q7NgRWfXZnp1NZei3
```

### Bioauth key import

Copy the secret phrase and import it into keystore.

```shell-session
$ humanode-peer key insert --key-type kbai --suri "$SECRET_PHRASE" \ 
      --chain chainspec.json --scheme sr25519
```

Where:

* `--key-type kbai` - bioauth key type used in the Humanode networks.
* `--suri "$SECRET_PHRASE"` - your secret phrase (i.e. mnemonic) from the previous command.
* `--chain chainspec.json` - path to the Humanode chain specification file.

### Run the tunnel

The humanode peer uses `9944` RPC endpoint by default. You are free to use any of your choices. But don't forget to explicitly specify the same port during the peer run in case using a different one from `9944`.

Run the tunnel using `ngrok-wrapper`

```shell-session
$ ngrok-wrapper 9944
```

### Run the peer

There are 2 options to run it:

* Using `--rpc-url-ngrok-detect` subcommand to automatically detect RPC URL from `ngrok-wrapper` that you have already launched before.

  ```shell-session
  $ humanode-peer --name "$NAME" --validator --chain chainspec.json \ 
        --rpc-url-ngrok-detect --rpc-cors all
  ```
* You can manually specify RPC URL from `ngrok-wrapper` output console.

  <pre class="language-shell-session"><code class="lang-shell-session"><strong>$ humanode-peer --name "$NAME" --validator --chain chainspec.json \
  </strong>      --rpc-url "$RPC_URL" --rpc-cors all
  </code></pre>

Where:

* `--name "$NAME"` - where `$NAME` is your Humanode peer name.
* `--validator` - means that you join the network as a block producer.
* `--chain chainspec.json` - a path to the file that contains Humanode chain specification.
* `--rpc-url "$RPC_URL"` - the peer's RPC URL, where `$RPC_URL` is the URL that you noted at the `ngrok-wrapper` configuration step, or your own URL if you're not using `ngrok-wrapper`.
* `--rpc-url-ngrok-detect` - to detect peer's RPC URL automatically from `ngrok-wrapper` (mutually exclusive with `--rpc-url`).

{% hint style="info" %}
We strongly recommend to use `--rpc-url-ngrok-detect` subcommand to avoid facing unexpected issues.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.humanode.io/docs/distribution/running-the-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
