# Operation Tutorial

## Join the Network

### Hardware Guide

<table><thead><tr><th width="145">CPU</th><th width="117">RAM</th><th>Storage</th><th>Bandwidth</th></tr></thead><tbody><tr><td>16 cores</td><td>16GB</td><td>2TB (SSD recommended for better speed)</td><td>Up / Down 100Mbps, Fixed Public IP</td></tr></tbody></table>

\*During the testnet, the validator's storage usage is small, expected to be in the hundreds of gigabytes level.

### Prerequisites

Ensure that the following software is installed in order to properly compile and run the Titan Consensus Node:&#x20;

* **Git**: for cloning the source code&#x20;
* **Go 1.21+**: for compiling the source code, Titan nodes are written in the Go language, make sure you have Go 1.21 or later installed

## Configuration <a href="#configuration" id="configuration"></a>

### Install titan cli

#### 1. Clone Titan's code repository

```bash
git clone https://github.com/Titannet-dao/titan-chain.git
```

#### 2. Enter the repository directory and build Titan CLI

```bash
cd titan-chain
go build ./cmd/titand
```

#### 3. Put Titan CLI into /usr/local/bin

```bash
cp titand /usr/local/bin
```

### Initialize Titan Validator

**1. Initialize the node**

Use Titan CLI initialize your node, this step will configure the node and create necessary file structure

* Open the terminal
* Run the following command, where `<your-custom-moniker>` is the unique name of your node you choose for identification in the network

```bash
titand init <your-custom-moniker> --chain-id titan-test-3
```

This command will create a `.titan` folder under your user directory, which contains all necessary configuration files and data folders. This is the fundamental configuration environment for the node operation.

**2. Set the custom name for the node**

After initialization, you need to set or confirm the custom name of the node, which will be used to identify your name in the network

* Open the configuration file with `vim` editor

```bash
vim ~/.titan/config/config.toml
```

* Find the item `moniker` in the opened file. It should show the name you just set during initialization. If you want to modify it, you can do it here.&#x20;

```toml
# A custom human readable name for this node
moniker = "<your-custom-moniker>"
```

Replace `<your-custom-moniker>` with your prefered node name, this name will represent your node in the network.

* Save and close the file. In `vim`, press `Esc` to exit the edit mode, enter `:wq` (write and quit) and press `Enter` to save your change and quit the editor.&#x20;

**3. Confirm the configuration**

* We suggest you to examine the directory structure of `.titan` to ensure all files are correctly created. You can use the following command.

```bash
ls -la ~/.titan
```

Check whether sub directories `config` and `delta` exist.

Now, your Titan node has been successfully initialized with a custom name, and ready for connecting to the network and synchronizing data. These settings ensure your node can normally be identified and operates in Titan network.&#x20;

### Configure Network Connections and Genesis Files

#### 1.Download and configure the genesis file

{% code overflow="wrap" %}
```bash
wget https://raw.githubusercontent.com/Titannet-dao/titan-chain/main/genesis/genesis.json
mv genesis.json ~/.titan/config/genesis.json
```
{% endcode %}

#### 2. Seeds & Peers

2.1 Understand Seeds and Persistent Peers

When launching a Titan validator node, it is crucial to establish connections with other nodes in the network. Seeds and Persistent Peers are two ways to help new nodes discover and maintain network connectivity.

{% hint style="info" %}
* **Seeds**: The information of these nodes is used to help the new node to get the initial connection point of the network. Once the initial connection is established, the node will try to establish connections with more nodes of the network.
* **Persistent Peers:** Unlike seed nodes, once the persistent peers are connected, the nodes will attempt to maintain a long-term connection to these nodes, which is critical to the stability of the network.
{% endhint %}

2.2 Edit the configuration file

Configuration file `config.toml` in `~/.titan/config`is the main file to configure node connections

* Open the configuration file

```bash
vim ~/.titan/config/config.toml
```

* Find `seeds`and`persistent_peers` and edit accordingly

{% code overflow="wrap" %}
```toml
# Example: set seed nodes
seeds = "<seed node id 1>@<seed node address 1>:26656,<seed node id 2>@<seed node address 2>:26656"

# Example: set persistent peer nodes
persistent_peers = "<node id 1>@<node address 1>:26656,<node id 2>@<node address 2>:26656"
```
{% endcode %}

2.3 Add a provided seed node

Configure your node with known stable seed nodes to enhance connection reliability when the node starts:

```bash
seeds = "bb075c8cc4b7032d506008b68d4192298a09aeea@47.76.107.159:26656"
```

2.4 Use Quicksync Address Book

Downloading and using the Quicksync Address Book speeds up the synchronization of your nodes with the network, allowing them to integrate into the network faster.

* Download and move the address book to the correct location:

{% code overflow="wrap" %}
```bash
wget https://raw.githubusercontent.com/Titannet-dao/titan-chain/main/addrbook/addrbook.json
mv addrbook.json ~/.titan/config/addrbook.json
```
{% endcode %}

### Configure Gas Prices and Fees in Titan-test

Configuring reasonable Gas prices and fees is an important measure to protect nodes from abuse while maintaining economic efficiency. Setting these parameters ensures that only those transactions that pay sufficient fees are processed.

1\. Understand Denomination and Unit Conversion

In the Titan-test-1 network, the smallest unit of currency is the `uttnt`, where `1 ttnt` equals `1,000,000 uttnt` . This conversion is very important because all transaction fees are calculated and paid in `uttnt`.

2\. Calculate transaction fees

The transaction fee is calculated using the following formula, which is the fee that the network has to pay to run the transaction:

```
fees = ceil(gas * gasPrices)
```

where

* `gas` is the number of gas consumed in the execution of the transaction.
* `gasPrices`is the cost of per unit of gas



3\. Set the minimum gas price

Setting an appropriate minimum gas price (`min-gas-price`) is a key measure to ensure that your nodes do not process low-fee transactions. This not only protects your node from wasted resources (e.g. spam attacks), but also ensures that your node runs efficiently and economically.

* Set the minimum gas price in `~/.titan/config/app.toml`

```toml
# set the minimum gas price the validator is willing to accept
minimum-gas-prices = "0.0025uttnt"
```

4\. Recommended gas price

For the current Titan-test-1 network, the suggested price of Gas is `0.0025 uttnt`. This price is sufficient to fend off most spam transactions while keeping the network attractive.&#x20;

The full node keeps all unconfirmed transactions in its memory pool. Setting a reasonable minimum Gas price is an important strategy to ensure that only transactions that meet the fee criteria are added to the memory pool. Doing so protects your nodes from low-quality or malicious transactions that could lead to service denials.

### Manage your node using systemd

To ensure that your Titan node runs stably as a background service, it is critical to manage the titand service using systemd, which helps to automatically restart the node if it encounters problems.

**1. Create a systemd service file**

You need to create a new systemd service file `/etc/systemd/system/titan.service`, this file will define how to start and manage your Titan node.&#x20;

* Open a terminal and enter the following command to create and edit the service file:

```bash
sudo vim /etc/systemd/system/titan.service
```

* In the editor, paste the following configuration. These settings define how to start the service and how to restart it automatically if it fails:

```ini
[Unit]
Description=Titan Daemon
After=network-online.target

[Service]
User=root
ExecStart=/usr/local/bin/titand start
Restart=always
RestartSec=3
LimitNOFILE=4096

[Install]
WantedBy=multi-user.target
```

* **Description**: Description of the service
* **After**: Specifies that `titand`service needs to start after the network is fully up
* **User**: Specifies the user who will run the service. For security reasons, it may be necessary to create and specify a non-root user
* **ExecStart**: Specifies the start command
* **Restart**: Set to `always` to automatically restart the service if it fails
* **RestartSec**: The number of seconds to delay restart after an error
* **LimitNOFILE**: Increases the file descriptor limit to help nodes manage large numbers of connections

**2. Enable and start the service**&#x20;

After saving the file and exiting the vim editor, execute the following commands to enable and start the service:

```bash
sudo systemctl enable titan.service
sudo systemctl start titan.service
```

These commands will ensure that the Titan service starts automatically at system startup and restarts automatically if any problems occur during operation.

**3. Check service status**

* Check the status of the Titan service to ensure that it is running:

```bash
sudo systemctl status titan.service
```

* If you need to see the logs of the service, you can use:

```bash
journalctl -u titan.service
```

With the above steps, your Titan node will be running securely and stably as a systemd service, able to efficiently handle transactions and data on your network. This setup helps you reduce manual intervention and ensures that the node is always online and available.



### **Start and Configure a Titan Validator Node**

Before you start running a Titan Validator, make sure your node is set up and synchronized to the latest block height. The following guide will help you step by step to become a validator:

#### Create your account

1. **Generate a new key pair**: Create a new key pair using Titan Daemon (titand), this command will generate a new account and associated recovery phrase.

```bash
titand keys add <name>
```

* `<name>`: Choose a name for your key pair
* Be sure to keep the generated phrase safe, as they can be used to recover your account. Recovery phrase can also be used to import wallet software such as Keplr.

2. **Transfer tokens to your address**：

* Transfer a certain number of TTNT tokens to your new account address, which will be used to pay transaction fees as well as to fund self-delegated to the validator node.

#### Create the validator

1. **Create validator config file:**&#x20;

* First, create and edit the validator config file:

```
vim ~/validator.json
```

Replace parameters:

* Add following info into the file:

```
{
 "pubkey":  "<pubkey>",
 "amount": "<amount>uttnt",
 "moniker": "<moniker>",
 "commission-rate": "0.07",
 "commission-max-rate": "1.0",
 "commission-max-change-rate": "0.01",
 "min-self-delegation": "1",
 "identity": "<identity>",
 "website": "<website>",
 "security": "<security>",
 "details": "<details>"
}
```

Parameter descriptions:

* `<pubkey>`: Use the command `titand tendermint show-validator` to obtain the public key of the validator
* `<amount>`: The number of TTNT tokens you want to delegate to the validator.
* `<moniker>`: The name of your validator. This is a custom name used to identify your node in the network.
* `<commission-rate>`sets the commission rate charged by your validator. For example, if it is set to 0.07, this means that 7% of the rewards received by the principal will be charged as commission.
* `<commission-max-rate>`The maximum commission rate your validator can charge. This is a security measure to protect the principal from arbitrary commission increases by the validator.
* `<commission-max-change-rate>`The maximum rate of change your validator can make on the stated commission rate. This defines how often you can change the commission rate and how much can be adjusted per change.
* `<min-self-delegation>`is the minimum number of tokens that the validator must consistently delegate on its own nodes. This parameter ensures that validators have enough financial incentive to maintain honest and responsible behavior.
* `<identity>`: Optional identity signature (e.g., UPort or Keybase)
* `<website>`: Optional website of the validator
* `<security>`: Optional security email for the validator
* `<details>`: Optional detail information of the validator

2. Use the config file to create the validator node:

Use the editted config file to create the validator node:

```
titand tx staking create-validator ~/validator.json --from <account> --fees 500uttnt --ip <ip>
```

Parameter descriptions:

* `<account>`: specify which account is used in for signing transactions. This should be the name of the account you created, which should have enough balance to cover transaction fees.
* `<ip>`: Your public IP address. This parameter needs to be set if you intend your node to be a public peering point. If not, you can omit this parameter.

#### Notes

* **Becoming an active validator**: Initially, your validator may not immediately become part of the active validator set, as a sufficient total amount of delegation is required to enter the active set.&#x20;
* **Delegate operations**: Users can use a wallet application such as Keplr to delegate TTNT to you or any other validator.&#x20;
* **Monitor Status**: You can use a blockchain browser such as Mintscan to monitor your validator status and ranking.

### Using the Titan Blockchain Browser to Assist in Setting Up and Monitoring Validator Nodes

When setting up and running Titan validator nodes, it is extremely useful to have access to a dedicated Titan blockchain browser. Such a tool can help you monitor the network status in real-time, confirm that transactions are successful, and check the performance of your node and other nodes.

**Recommended blockchain browser:**

* [Explorer 1](https://explorers.titannet.io/en)
* [Explorer 2 (ping.hub)](https://testnet.ping.pub/Titan%20Network%20Testnet)
