> For the complete documentation index, see [llms.txt](https://docs.trac.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trac.network/documentation/validators/installation/testnet.md). Agents can also search and read this documentation through its [MCP server](https://docs.trac.network/~gitbook/mcp).

# Testnet

Validators install and use instances of the Main Settlement Bus (MSB). Learn how to install and operate the MSB for Trac Network Testnet on Windows, macOS, and Linux.

First we need to install **Node.js**. If you are not tech-savvy, don't worry, it's straightforward. If you already have a compatible version of Node.js installed, you can skip its installation and move straight to the Pear installation. The commands below use Node.js `22.22.0` and npm `11.6.1`.

> **Important:** Please use a separate folder for Testnet. If you already run a Mainnet or Hypermall validator, follow the folder name suggested below so the installations do not overlap.

### **Prerequisites**

We will use **Git** to download the Testnet MSB. If you do not have Git installed, please follow the official instructions for [Windows](https://git-scm.com/install/windows), [macOS](https://git-scm.com/install/mac), or [Linux](https://git-scm.com/install/linux).

Once installed, open a terminal or PowerShell and check:

```sh
git --version
```

This should print a Git version number. If the command is not found after installation, please reopen your terminal or PowerShell and try again.

#### Installing Node.js

{% tabs %}
{% tab title="Windows" %}
Open PowerShell (**right-click > Run as administrator**) and enter:

```powershell
# Allow script execution for this session:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned

# Download and install fnm:
winget install Schniz.fnm

# Set some environment options:
fnm env --use-on-cd | Out-String | Invoke-Expression

# Download and select Node.js:
fnm install 22.22.0
fnm use 22.22.0

# Install npm:
npm install -g npm@11.6.1

# Verify the Node.js version:
node -v # Should print "v22.22.0".

# Verify the npm version:
npm -v # Should print "11.6.1".
```

If PowerShell does not find `fnm` after installation, please reopen PowerShell as administrator and continue from the `fnm env` command.
{% endtab %}

{% tab title="macOS / Linux" %}
Open a terminal / console and enter:

```bash
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

# Load nvm without restarting the shell:
\. "$HOME/.nvm/nvm.sh"

# Download and select Node.js:
nvm install 22.22.0
nvm use 22.22.0

# Install npm:
npm install -g npm@11.6.1

# Verify the Node.js version:
node -v # Should print "v22.22.0".
nvm current # Should print "v22.22.0".

# Verify the npm version:
npm -v # Should print "11.6.1".
```

Should `curl` for some reason not exist, install it first. If it is missing on macOS, you can try `/usr/bin/curl` instead of just `curl`.

{% endtab %}
{% endtabs %}

Once you have confirmed that `node -v` and `npm -v` return no errors and print version numbers, we can proceed.

### **Installing Pear Runtime**

Next is installing the **Pear Runtime**. The MSB runs on top of it for efficient execution. In principle, running the MSB using plain Node.js works, but it is recommended to use Pear.

Simply execute the following in your shell / console / terminal:

```sh
npm i -g pear
pear -v
```

If Pear asks you to set the paths after installation, please execute the `export` command that is provided.

`pear -v` should print the version that you installed, and you are ready to continue installing the MSB. Please use the exact Git tag shown below for Testnet: **v0.3.0-beta.3.1**.

### **Install Testnet MSB Validator**

We can now download the MSB from GitHub and select the Testnet release. For a new installation, choose your operating system below. The commands create a folder called `msb-testnet` and install the MSB inside it.

If you already have a Testnet installation, please follow **Updating an existing Testnet validator** below.

{% tabs %}
{% tab title="Windows" %}
In PowerShell, running as administrator, open the folder where you would like to keep your validator and enter:

```powershell
git clone https://github.com/Trac-Systems/main_settlement_bus.git msb-testnet
cd msb-testnet
git fetch --tags
git checkout v0.3.0-beta.3.1
npm install
```

Once the installation finishes without errors, we can start the MSB:

```powershell
node --max-old-space-size=4096 scripts/pear-runner.js --stores-directory ./experimental_store --network testnet
```

{% endtab %}

{% tab title="macOS / Linux" %}
In your terminal, open the folder where you would like to keep your validator and enter:

```bash
git clone https://github.com/Trac-Systems/main_settlement_bus.git msb-testnet
cd msb-testnet
git fetch --tags
git checkout v0.3.0-beta.3.1
npm install
```

Once the installation finishes without errors, we can start the MSB:

```bash
npm run start -- --stores-directory ./experimental_store --network testnet
```

{% endtab %}
{% endtabs %}

**Updating an existing Testnet validator**

If your validator already runs on the current Testnet and you are keeping its existing database, updates work like this:

* Stop your MSB with `/exit`, or stop its PM2 process, and back up the complete `experimental_store/testnet` folder.
* From your existing `msb-testnet` installation folder, select the release and install its dependencies:

```sh
git fetch --tags
git checkout v0.3.0-beta.3.1
npm install
```

* Start again using the command for your operating system above. Keep the same `--stores-directory` value you used before and keep `--network testnet`.
* Check that your Testnet MSB address is the same and let your MSB sync. Keeping the complete database also keeps your writing key. If you are still registered as a writer, there is no need to remove and add it again. If you are whitelisted but no longer registered as a writer, type `/add_writer` and hit Enter.
* Skip the first-time identity setup and whitelist request below.

> **Note:** If you used a different store directory, use that directory for your backup and restart. If the MSB asks you to set up an identity again, please check the directory before creating a new identity.

**If you are restoring your Testnet validator into a new store**

A new store gets a new writing key, even when you restore your existing Testnet seed phrase or `keypair.json` and your MSB address stays the same. Using the same folder name after deleting the database also creates a new store. If the network still has your old writing key registered, your new instance cannot validate until you update that registration.

To get your validator running with the new writing key, please follow these steps:

1. Make sure the old instance is stopped. Start the new store with `--network testnet`, restore your existing **Testnet** identity, check that your MSB address is the same, and let it sync. To restore from your Testnet seed phrase, choose option `2` when asked to set up your identity.
2. In the new instance's validator screen, type `/remove_writer` and hit Enter. Please wait until the removal has been processed before continuing. You can check with `/node_status <MSB Address>`: `IsWriter` should be `false`. If it already shows `false` after syncing, you can skip the removal.
3. Then type `/add_writer` and hit Enter. This registers the writing key of your new store automatically. Wait for confirmation that your validator has been added.

You do not need to request whitelisting again when restoring the same whitelisted Testnet MSB address.

### **Post Install**

The command above starts your MSB on Testnet. `./experimental_store` is the directory selected for this validator. The database is located in `experimental_store/testnet`, and this folder also contains a backup of your identity.

> **Note:** To run multiple instances, use a different directory for each one, such as `./experimental_store2`. Each validator should have its own Testnet identity.

After the MSB starts for the first time without an identity, you should see:

```
[1]. Generate new keypair
[2]. Restore keypair from 12 or 24-word mnemonic
```

For a new validator, please type `1` and hit Enter. The MSB will show you the seed phrase. Keep it somewhere safe and private.

> **Important:** Never use your Mainnet private keys or seed phrase on Testnet. Please generate a separate seed phrase for your Testnet validator.

Let's also make a backup of your `keypair.json` file.

{% tabs %}
{% tab title="Windows" %}
Use your file explorer to copy `msb-testnet/experimental_store/testnet/db/keypair.json` to a private backup folder outside your MSB installation.
{% endtab %}

{% tab title="macOS / Linux" %}
Open another terminal in `msb-testnet` and enter the following, replacing `/some/backup/location/` with your own existing backup folder:

```bash
cp experimental_store/testnet/db/keypair.json /some/backup/location/
```

{% endtab %}
{% endtabs %}

The `keypair.json` file contains the seed phrase that you can use to restore your Testnet identity in a new installation. Keep this file private, just like the seed phrase itself.

Restoring only this file or your Testnet seed phrase into a new store restores your address, but the new store has a different writing key. Please follow the steps for restoring into a new store in Install Testnet MSB Validator to register it.

If you would like a backup of the complete database, including its writing key, stop your MSB and copy the entire `experimental_store/testnet` folder.

On a new setup, seeing `isWriter: false` and a balance of `0` is expected. We will get your validator whitelisted in the next step.

Your validator screen should show something like this (shortened example):

```
#####################################################################################
# MSB Address:    testtrac1... #
# MSB Writer:     <your writing key> #
#####################################################################################
...
isIndexer: false
isWriter: false
MSB Unsigned Length: 12345
MSB Signed Length: 12345
Balance: 0
```

Your own Testnet MSB address and writing key will appear here. The length values above are just examples and will change as your validator syncs.

To stop your MSB, enter `/exit` in the validator screen. Use the `Ctrl+C` keys on your keyboard only as a last resort.

To restart, use the same startup command from your `msb-testnet` folder, with the same directory and `--network testnet`.

### **Getting Whitelisted**

If your Testnet validator is not whitelisted yet, we can arrange that next. First, request some **tTNK** from the [Testnet faucet](https://faucet.trac.network/), using the MSB address shown in your validator screen. Testnet addresses start with `testtrac1`.

You can view your transactions in the [Testnet explorer](https://testnet.trac.network/). TAP Wallet also supports Testnet.

To join as a Testnet validator, please contact the team in [Trac Network Discord](https://discord.gg/trac) and share your Testnet MSB address. Once the team confirms that your address has been whitelisted, type `/add_writer` in the validator screen and hit Enter:

```
/add_writer
```

Wait for confirmation that your validator has been added. Your validator can then validate Testnet transactions and receive fees in tTNK. You can use the built-in wallet commands to check balances and make transfers.

> **Important:** Please run each validator directory and identity only once at a time. Running the same identity in two instances can cause repeated logins and logouts.

### Running the MSB in Background&#x20;

ere are several ways to run the MSB in the background. For managing your instances across operating systems, we recommend the Node.js package **PM2**. [See here](https://pm2.keymetrics.io/docs/usage/quick-start/) for installation instructions. Using the npm method is fine:

```sh
npm install -g pm2
```

Once you have completed the setup above, enter `/exit` in your validator screen. Then, from your `msb-testnet` folder, start the same validator in the background like this:

{% tabs %}
{% tab title="Windows" %}

```powershell
pm2 start node --name "My Testnet MSB #1" --no-autorestart -- --max-old-space-size=4096 scripts/pear-runner.js --stores-directory ./experimental_store --network testnet
```

{% endtab %}

{% tab title="macOS / Linux" %}

```bash
pm2 start "npm run start -- --stores-directory ./experimental_store --network testnet" --name "My Testnet MSB #1" --no-autorestart
```

{% endtab %}
{% endtabs %}

> **Important:** If you use PM2, please start your instances using the `--no-autorestart` flag, otherwise you may run into issues.

For additional validators, choose a different process name and validator directory for each one.

You can check your validator's output with:

```sh
pm2 logs "My Testnet MSB #1"
```

To return to the interactive validator screen, stop the background instance with `pm2 stop "My Testnet MSB #1"`, then use your usual startup command. After leaving the validator screen with `/exit`, you can resume the background instance with `pm2 restart "My Testnet MSB #1"`.

Check the PM2 documentation for further details, as it is a powerful tool for managing programs that run in the background.

### Further Information

*This guide covers the basic steps to install and run an MSB validator node.*

*If you would like to learn more or explore additional configuration options, please refer to the official* [*repository*](https://github.com/Trac-Systems/main_settlement_bus)*.*
