> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fortytwo.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start

<Badge color="gray">P2P</Badge>
<Badge color="gray">Fortytwo P2P Relay</Badge>
<Badge color="green">Installing</Badge>
<Badge color="blue">Launching</Badge>
<Badge color="blue">Updating</Badge>
<Badge color="blue">Stopping</Badge>

<Callout icon="sparkle" color="#0037ff" iconType="regular">
  [Get Relay Access <Icon icon="arrow-up-right" />](https://tally.so/r/9qN9Ap)

  <Warning>
    **Please ensure you have received an acceptance email containing your whitelisted public wallet address before attempting to launch the Relay Node. A unique whitelisted wallet address is required for each device on which the Relay Node is installed.**
  </Warning>
</Callout>

## Recommendations

* It is recommended to have previous **experience of operating relay or being Validator/Operator on a blockchain** with knowledge of [<Icon icon="docker" /> Docker <Icon icon="arrow-up-right" />](https://www.docker.com/).
* It is best to run Fortytwo P2P Relay on a **dedicated server**. Both P2P Relay Node and P2P Inference Node can run on the same server if set up correctly ([read more here](/docs/relay-quick-start#how-to-run-a-relay-node-alongside-an-inference-node)).
* **Staying online 24/7** will greatly affect the node's quality and rewards.

## 1. Installing the P2P Relay Node

<Steps>
  <Step title="Review the requirements">
    Being a Relay Noderunner has specific'[Relay Node Requirements](/docs/relay-requirements)'.

    Make sure that your system/virtual machine meets all requirements before proceeding.

    <Note>
      **Requirements:**<br />
      *hardware*<br />
      **CPU on x86\_64 architecture**<br />
      *software*<br />
      **OS:** <Icon icon="windows" iconType="solid" /> Windows or <Icon icon="linux" iconType="solid" /> Linux<br />
      **Installed** [<Icon icon="docker" /> Docker <Icon icon="arrow-up-right" />](https://docs.docker.com/get-started/get-docker/)<br />
      **Installed** [<Icon icon="git" /> Git <Icon icon="arrow-up-right" />](https://git-scm.com/download/)<br />
      **Private key from an EVM-Compatible Web3 account**
    </Note>
  </Step>

  <Step title="Get the repository">
    <Card title="Fortytwo P2P Relay Setup" icon="github" href="https://github.com/Fortytwo-Network/fortytwo-p2p-relay-docker">
      Clone the repository
    </Card>

    <Accordion title="Cloning the Repository from GitHub">
      *Note: We don't recommend downloading and setting up the repository archive manually as it will be harder to keep the Fortytwo Container up to date.*

      <Tabs>
        <Tab title="macOS" icon="apple">
          <Steps>
            <Step>
              **If you have previously removed git** (git comes preinstalled on macOS):

              Install [<Icon icon="git" /> Git <Icon icon="arrow-up-right" />](https://git-scm.com/install/)<br />
              or install Xcode Command Line Tools:

              ```
              xcode-select --install
              ```
            </Step>

            <Step>
              Open the **Terminal**.
            </Step>

            <Step>
              Navigate to your preferred installation directory with `cd` command, or run the following command to continue installation in the **default location** in your home directory:

              ```bash theme={null}
              mkdir -p ~/FortytwoRelay && cd ~/FortytwoRelay
              ```
            </Step>

            <Step>
              Run the following commands to clone the node package and enter the folder:

              ```bash theme={null}
              git clone https://github.com/Fortytwo-Network/fortytwo-p2p-relay-docker
              cd fortytwo-p2p-relay-docker
              ```
            </Step>
          </Steps>
        </Tab>

        <Tab title="Windows" icon="windows">
          <Steps>
            <Step>
              **If you don't have Git installed:**<br />

              Install [<Icon icon="git" /> Git <Icon icon="arrow-up-right" />](https://git-scm.com/download/win).
            </Step>

            <Step>
              Open **PowerShell as Administrator**.
            </Step>

            <Step>
              Navigate to your preferred installation directory with `cd` command, or run the following command to continue installation in the **default location** in your home directory:

              ```bash theme={null}
              New-Item -Path "$HOME\FortytwoRelay" -ItemType Directory -Force; Set-Location "$HOME\FortytwoRelay"
              ```
            </Step>

            <Step>
              Run the following commands to clone the node package and enter the folder:

              ```bash theme={null}
              git clone https://github.com/Fortytwo-Network/fortytwo-p2p-relay-docker
              cd fortytwo-p2p-relay-docker
              ```
            </Step>
          </Steps>
        </Tab>

        <Tab title="Linux (Ubuntu/Debian)" icon="linux">
          <Steps>
            <Step>
              **If you don't have Git installed:** Install [<Icon icon="git" /> Git <Icon icon="arrow-up-right" />](https://git-scm.com/install/linux).
            </Step>

            <Step>
              Open **Terminal**.
            </Step>

            <Step>
              Navigate to your preferred installation directory with `cd` command, or run the following command to continue installation in the **default location** in your home directory:

              ```bash theme={null}
              mkdir -p ~/FortytwoRelay && cd ~/FortytwoRelay
              ```
            </Step>

            <Step>
              Run the following commands to clone the node package and enter the folder:

              ```bash theme={null}
              git clone https://github.com/Fortytwo-Network/fortytwo-p2p-relay-docker
              cd fortytwo-p2p-relay-docker
              ```
            </Step>
          </Steps>
        </Tab>
      </Tabs>
    </Accordion>
  </Step>

  <Step title="Setup the `.env` file">
    Create an `.env` file from the `.env.example` reference file and update environment variables:

    ```bash theme={null}
    cp .env.example .env
    ```

    Open the `.env` file and specify the unique credentials for the node:

    * `FT_ACCOUNT_PRIVATE_KEY` — Unique Web3 account private key<br />
    * `HOST_PUBLIC_IP` — Your IP/your server IP address<br />
          <Warning>
            Your private key must be different from the account that you use with your Inference Node.
          </Warning>

    <Accordion title="Unwrap for .env setup example">
      ```bash theme={null}
      FT_ACCOUNT_PRIVATE_KEY=$YOUR_UNIQUE_PRIVATE_KEY
      FT_RPC_SERVICE_PORT=42420
      FT_NODE_LISTENER_PORT=42042

      IPFS_SWARM_PORT=4001
      IPFS_DATA_PATH=/data/ipfs
      IPFS_MOUNT_PATH=/data/ipfs_ipns
      HOST_PUBLIC_IP=$YOUR_IP_ADDRESS
      ```
    </Accordion>

    Read the '[Environment Setup](/docs/relay-env-setup)' page for more details.
  </Step>

  <Step title="Set up the ports">
    Check the `.env` file and ensure that the ports defined with the `FT_NODE_LISTENER_PORT` and `IPFS_SWARM_PORT` are publicly accessible over both **TCP** and **UDP**.
    **Static public IP** is required.

    '[Ports Availablity Verification](/docs/ports)' can help you check if the network will be able to see your node.
  </Step>

  <Step title="Set up the folders">
    Inside the repository, create the following folders, which should match with the `IPFS_DATA_PATH` and `IPFS_MOUNT_PATH` defined in the `.env`:

    ```bash theme={null}
    mkdir -p /data/ipfs
    mkdir -p /data/ipfs_ipns
    ```
  </Step>
</Steps>

### How To Run a Relay Node Alongside an Inference Node

To run your Inference and Relay Nodes on the same machine at the same time, you need to:

<Steps>
  <Step title="Edit the .env file">
    * Change the default `FT_NODE_LISTENER_PORT` and `FT_RPC_SERVICE_PORT`. They have to be different from the Inference Node ports, which by default are  `42042` and `42420` respectively.
    * Define a unique `FT_ACCOUNT_PRIVATE_KEY`, it must be different from the account that you use with your Inference Node.

    Read the '[Environment Setup](/docs/relay-env-setup)' page for details.
  </Step>

  <Step title="Ensure that FT_NODE_LISTENER_PORT is publicly accessible over both TCP and UDP">
    Note that **static public IP** is required.

    '[Ports Availablity Verification](/docs/ports)' can help you check if the network will be able to see your node.
  </Step>
</Steps>

## 2. Launching Fortytwo P2P Relay

If restarting your node after relaunching the terminal/OS, don't forget that the following should be executed from the node repository folder, where your `.env` and `docker-compose.yml` are located.

<Steps>
  <Step title="Update the repository">
    To make sure that your repo is up to date, before each start, get the latest updates with the `git pull` command:

    ```bash theme={null}
    git pull
    ```
  </Step>

  <Step title="Launch Docker">
    Launch [<Icon icon="docker" /> Docker <Icon icon="arrow-up-right" />](https://docs.docker.com/get-started/get-docker/) and wait until its interface says "Engine running".
  </Step>

  <Step title="Build the Docker Compose services">
    ```bash theme={null}
    docker compose build
    ```
  </Step>

  <Step title="Run the services in the background">
    ```bash theme={null}
    docker compose up -d
    ```
  </Step>
</Steps>

### How to Make Sure it Works?

If everything went successfully, you should now be able to open **Docker** application and see the `fortytwo-p2p-relay-docker` process running.

If you unwrap it and go to `fortytwo-relay` container, you can see the logging of the node running successfully. The node periodically tests its health and reports on your relay address status, like in this example:

```bash theme={null}
fortytwo-relay  | UTC 20XX-XX-25 14:25:14.520081  INFO Check health
fortytwo-relay  | UTC 20XX-XX-25 14:25:14.520106  INFO Relay address is public. Current address /ip4/X.XXX.XXX.XX/tcp/42042
```

The most common error you might encounter is an issue with closed ports:

```bash theme={null}
WARN Relay address status is unknown (attempt X/3). Please ensure that your node listener port is accessible from the outside.
ERROR Failed to determine NAT status after 3 attempts.
```

In this case, please refer to the '[Environment Setup](/docs/relay-env-setup)' page.

## 3. Operating Your Node

The node will remain fully operational until it is terminated by the user or the system restarts.

### Updating Fortytwo P2P Relay

The node **components update automatically** every time it is launched and while operational.

However, you need to **manually update the repository** to get the latest evniroment updates.

At every start, execture the following command.

```bash theme={null}
git pull
```

If running stable, check for the updates on the [Changelog page](/changelog). When you see `[|] Fortytwo P2P Relay` update available, stop your node, run the `git pull` command, and then restart the node. Here are the commands that will help you to compare your current commit version versus the remote version:

```bash theme={null}
git fetch
git log -1 origin/main --format="Remote: %h %ci"
git log -1 --format="Local:  %h %ci"
```

### Stopping Fortytwo P2P Relay

To stop the running container, either stop it from the Docker interface, or execute the following command from the same folder where the `docker-compose.yml` is located:

```bash theme={null}
docker compose down
```
