# Mainnet: Sourced Installation and Setup

## Current Mainnet

Below is the Source Chain mainnet and its current status. You will need to know the version tag for installation of the `sourced` binary.

Additional resources, guides, snapshots, and explorers can be found further down at: [Mainnet Resources](https://docs.sourceprotocol.io/nodes-and-validators/mainnet-resources)

For details of upgrades on the current mainnet, as well as syncing, you can check out the Mainnet Repo.

{% embed url="<https://github.com/Source-Protocol-Cosmos/source>" %}

If you get stuck, please ask on [Discord.](https://discord.gg/zj8xxUCeZQ)

| chain-id | Current Github version tag |
| -------- | -------------------------- |
| source-1 | v3.0.1                     |

{% embed url="<https://github.com/Source-Protocol-Cosmos/source>" %}

{% embed url="<https://github.com/Source-Protocol-Cosmos/mainnet>" %}

## Minimum Hardware Requirements

The minimum recommended hardware requirements for running a validator for the Source Chain testnets are:

| Requirements                                                                          |
| ------------------------------------------------------------------------------------- |
| <ul><li>16GB RAM</li><li>200GB of disk space</li><li>2 Cores (modern CPU's)</li></ul> |

{% hint style="warning" %}
These specifications are the minimum recommended. As Source Chain is a smart contract platform, it can at times be very demanding on hardware. Low spec validators WILL get stuck on difficult to process blocks.
{% endhint %}

{% hint style="info" %}
Note that the blockchain accumulate data as the blockchain continues. This means that you will need to expand your storage as the blockchain database gets larger with time.
{% endhint %}

## Choose an Operating System

The operating system you use for your node is entirely your personal preference. You will be able to compile the sourced daemon on most modern linux distributions and recent versions of macOS.

{% hint style="info" %}
For the tutorial, it is assumed that you are using an Ubuntu LTS release.

If you have chosen a different operating system, you will need to modify your commands to suit your operating system.
{% endhint %}

## Install pre-requisites

```bash
# update the local package list and install any available upgrades
sudo apt-get update && sudo apt upgrade -y

# install toolchain and ensure accurate time synchronization
sudo apt install curl tar wget clang pkg-config libssl-dev libleveldb-dev jq build-essential bsdmainutils git make ncdu htop screen unzip bc fail2ban htop -y
```

## Install Go

Follow the instructions [here](https://golang.org/doc/install) to install Go.

For an Ubuntu LTS, you can probably use:

```bash
ver="1.19" && \
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \
sudo rm -rf /usr/local/go && \
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \
rm "go$ver.linux-amd64.tar.gz" && \
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bash_profile && \
source $HOME/.bash_profile && \
go version
```

## Clone Source Chain Repo

```
git clone https://github.com/Source-Protocol-Cosmos/source.git
```

### Compile sourced binary&#x20;

```
cd ~/source
git fetch
git checkout v3.0.1
make build && make install
```

### Initialize the Source directories and create the local genesis file with the correct chain-id:

```
sourced init <moniker-name> --chain-id=source-1
```

### Create a local key pair (or add existing key):

```
# Create new keypair
sourced keys add <key-name>

# Restore existing source wallet with mnemonic seed phrase.
# You will be prompted to enter mnemonic seed.
sourced keys add <key-name> --recover

# Query the keystore for your public address
sourced keys show <key-name> -a
```

Replace `<key-name>` with a key name of your choosing.

{% hint style="danger" %}
After creating a new key, the key information and seed phrase will be shown. It is essential to write this seed phrase down and keep it in a safe place. The seed phrase is the only way to restore your keys.
{% endhint %}

### Download Genesis File

```
curl -s  https://raw.githubusercontent.com/Source-Protocol-Cosmos/mainnet/master/source-1/genesis.json > ~/.source/config/genesis.json
```

### **Genesis sha256**

```
sha256sum ~/.source/config/genesis.json
```

**This should return:**

```
# ba2261082818227073bd8b49717a9781bf5c440c8e34e21ec72fb15806f047cc
```

### Seed nodes to add to config.toml

```
nano ~/.source/config/config.toml
```

Find the appropriate section and add:

```
# Comma separated list of nodes to keep persistent connections to persistent_peers = 
"96d63849a529a15f037a28c276ea6e3ac2449695@34.222.1.252:26656,0107ac60e43f3b3d395fea706cb54877a3241d21@35.87.85.162:26656"
```

### Set Minimum Gas Price

```
nano ~/.source/config/app.toml

0.25usource
```

### Start the chain

```
sourced start
```

It will take some time to catch up and sync to the network. Check your status with:

```
sourced status
```

### Running in production

Create a systemd file for your Source service:

```
sudo nano /etc/systemd/system/sourced.service
```

Copy and paste the following and update:

```
Description=Source daemon
After=network-online.target

[Service]
User=<YOUR_USERNAME>
ExecStart=/home/<YOUR-USERNAME>/go/bin/sourced start --home /home/<YOUR-USERNAME>/.source
Restart=on-failure
RestartSec=3
LimitNOFILE=4096

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

This assumes $HOME/.source to be your directory for config and data. Your actual directory locations may vary.

Enable and start the new service:

```
sudo systemctl enable sourced
```

```
sudo systemctl start sourced
```

Check status:

```
sourced status
```

Check logs:

```
journalctl -u sourced -f
```

## Setup cosmovisor

Follow [these](https://docs.sourceprotocol.io/nodes-and-validators/setting-up-cosmovisor) instructions to setup cosmovisor and start the node.

## Upgrade to a validator

To upgrade the node to a validator, you will need to submit a `create-validator` transaction:

```bash
sourced tx staking create-validator \
--amount 1000000000usource \
--commission-max-change-rate "0.1" \
--commission-max-rate "0.20" \
--commission-rate "0.1" \
--min-self-delegation "1" \
--details "validators write bios too" \
--pubkey=$(sourced tendermint show-validator) \
--moniker “<key-name>” \
--chain-id sourcechain-testnet \
--gas-prices 0.025usource \
--from <key-name>
```

## Backup critical files

There are certain files that you need to backup to be able to restore your validator if, for some reason, it damaged or lost in some way. Please make a secure backup of the following files located in `~/.source/config/`:

* `priv_validator_key.json`
* `node_key.json`

It is recommended that you encrypt the backup of these files.
