# How to run a validator node?

For a quickstart setup, follow the instructions [**here**](https://docs.ternoa.network/for-node-operators/how-to-setup-validator-node) on how to run a validator node. For a more detailed look into running Ternoa nodes, view our video below.

{% hint style="success" %}
Make sure to fully read the guide before you start doing anything. To follow along during our workshop, the guide is [**here**](https://docs.google.com/presentation/d/1rjMtUB-foRfSkruRWzVbFqKS1VRVvqmk4ohxJ_lNYrk/edit#slide=id.p), and you can skip to 9:17 in the video to begin.&#x20;
{% endhint %}

***

### Getting the binary (node/client)

There are two ways to get the binary: from the GitHub repo or to build it.

The easiest approach is to directly get the binary from the Ternoa chain GitHub [**repo**](https://github.com/capsule-corp-ternoa/ternoa-node). From the GitHub repo website, click on the Releases link and find the latest release with a binary attached to it.

The second approach is to manually build the client. You can follow the how-to-build-this-repo guide to understand how to do it. My recommendation is if you are going to follow this method, make sure that you have at least a quad-core CPU otherwise it will take ages to build.

Whatever method you choose, make sure that once you have the binary you place it in the right directory. Usually, the place is `usr/bin` or `/opt/ternoa.`

***

### Running the node

The key in correctly running the node is to use the right flags to connect to the right chain. Ternoa is currently running two networks, Ternoa Alphanet and Ternoa Mainnet, and depending if you want to deploy a test validator or a mainnet validator you need to pass either `--chain alphanet` or `--chain mainnet`, respectively.

**Here is an example on what flags you can/should use:**

```bash
/usr/bin/ternoa --name MyFirstNode --chain alphanet --base-path /opt/node-data --validator --state-cache-size 0 --execution wasm
```

**Let's see what those flags do:**

* name `X` - It sets the name of the validator node. `X` should be something unique.
* chain `X` - `X` can be either alphanet or mainnet. This tells the node which chain specification to use.
* base-path `X` - Defines where the blockchain data will be stored. If have an external disk attached, you that external disk for storing the data.
* validator - This runs the node in validator mode
* state-cache-size 0 - This fixes a bug that Substrate has.
* execution wasm - This runs the node in wasm mode. This is also used to fix a bug that is introduced in the Substrate's native runtime.

We recommend that you create a systemd service file that will run the node in the background and start it up on every restart. Instructions for that can be found in the linked workshop presentation [**here**](https://docs.google.com/presentation/d/1rjMtUB-foRfSkruRWzVbFqKS1VRVvqmk4ohxJ_lNYrk/edit#slide=id.p).

**Once the node is running, it will be visible in the telemetry UI and it will take time to sync up**

> [**Alphanet Telemetry UI**](https://telemetry.polkadot.io/#list/0x18bcdb75a0bba577b084878db2dc2546eb21504eaad4b564bb7d47f9d02b6ace)

> [**Mainnet Telemetry UI**](https://telemetry.polkadot.io/#list/0x6859c81ca95ef624c9dfe4dc6e3381c33e5d6509e35e147092bfbc780f777c4e)

While it's syncing up, you can run the following command to generate the session keys:

```bash
$ curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' http://localhost:9933 &> session_keys.txt
# The session keys will be stored inside the session_keys.txt file. Let’s printout that file.
$ cat session_keys.txt
```

The session keys are stored inside the "result" field. Make sure that you store it somewhere safe since it's going to be used in the next part of this guide.

To make sure that the session keys are properly inserted, stop the node and start it again. This is quite important to do because otherwise, the final steps in this guide might not work.


---

# 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://docs.ternoa.network/nodes-and-validators/how-to-run-a-validator-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.
