# Install Guide

### Build

WEMIX3.0 is implemented based on Ethereum, so the build method is the same as `go-ethereum`, except that `geth` has been changed to `gwemix`. The installation method of BP is the same as that of EN and uses the same binary. Therefore, it proceeds to build in the same procedure.

First, the developer downloads the [`go-wemix`](https://github.com/wemixarchive/go-wemix) source code by executing the following command on the Linux machine.

```
git clone https://github.com/wemixarchive/go-wemix.git
```

After that, go to the go-wemix directory and run the command below to start `gwemix` build. Depending on the USE\_ROCKSDB option, it is built as Rocksdb or Leveldb. Since the two databases are not compatible, you must check the db version when using chain data received from another machine.

This chapter is based on Ubuntu environment. To build gwemix from source code directly in Ubuntu environment, you need to follow the steps below.

{% tabs %}
{% tab title="Ubuntu 22.04 LTS" %}

#### Dependency

```
sudo apt-get update
sudo apt-get install -y build-essential golang
```

#### Rocksdb only

```
sudo apt-get install -y libsnappy-dev libjemalloc-dev
cd /usr/lib/x86_64-linux-gnu/
sudo ln -sf libjemalloc.so.2 libjemalloc.so.1
```

#### Download source code

```
git clone https://github.com/wemixarchive/go-wemix.git 
cd go-wemix
```

#### In case of rocksdb

```
make
```

#### In case of leveldb

```
make USE_ROCKSDB=NO
```

#### Copy and untar "build" to $GWEMIX\_HOME

```
GWEMIX_HOME='/opt/gwemix'
sudo mkdir -p $GWEMIX_HOME 
sudo chown $USER:$USER $GWEMIX_HOME
cp build/gwemix.tar.gz $GWEMIX_HOME/
cd $GWEMIX_HOME 
tar xvzf gwemix.tar.gz
```

#### Create .rc at $GWEMIX\_HOME with the following info

```
PORT=8588 
DISCOVER=1        # 1 for enable discovery mode, 0 for disable discovery mode
TESTNET=1         # 1 for Testnet or remove this line for Mainnet
SYNC_MODE=full
GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100"
```

#### Start gwemix

```
$GWEMIX_HOME/bin/gwemix.sh start
```

#### Check log

```
tail -F $GWEMIX_HOME/logs/log
```

{% endtab %}

{% tab title="Ubuntu 20.04.4 or 18.04.6 LTS" %}

#### Dependency

```
sudo apt-get update
sudo apt-get install -y build-essential 
```

#### Rocksdb only

```
sudo apt-get install -y libsnappy-dev libjemalloc-dev
cd /usr/lib/x86_64-linux-gnu/
sudo ln -sf libjemalloc.so.2 libjemalloc.so.1
```

#### Install go version 1.18.4

```
wget https://go.dev/dl/go1.18.4.linux-amd64.tar.gz 
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.18.4.linux-amd64.tar.gz 
export PATH=$PATH:/usr/local/go/bin 
source $HOME/.profile
```

#### Download source code

```
git clone https://github.com/wemixarchive/go-wemix.git 
cd go-wemix
```

#### In case of rocksdb

```
make
```

#### In case of leveldb

```
make USE_ROCKSDB=NO
```

#### Copy and untar "build" to $GWEMIX\_HOME

```
GWEMIX_HOME='/opt/gwemix'
sudo mkdir -p $GWEMIX_HOME 
sudo chown $USER:$USER $GWEMIX_HOME
cp build/gwemix.tar.gz $GWEMIX_HOME/
cd $GWEMIX_HOME 
tar xvzf gwemix.tar.gz
```

#### Create .rc at $GWEMIX\_HOME with the following info

```
PORT=8588 
DISCOVER=1        # 1 for enable discovery mode, 0 for disable discovery mode
TESTNET=1         # 1 for Testnet or remove this line for Mainnet
SYNC_MODE=full
GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100"
```

#### Start gwemix

```
$GWEMIX_HOME/bin/gwemix.sh start
```

#### Check log

```
tail -F $GWEMIX_HOME/logs/log
```

{% endtab %}
{% endtabs %}

When executing the `make`, `logrot` and `gwemix.tar.gz` are built at once for convenience of installation and are saved as compressed files in the `build` directory. The generated `gwemix.tar.gz` contains the following files.

```
bin/gwemix        ## gwemix binary
bin/gwemix.sh     ## gwemix control shell script
bin/logrot        ## log rotator
```

### **Build with Docker Image**

WEMIX3.0 can use docker images to solve cases where library dependencies are a problem. When building on Linux or MacOS X, you can build it through the following process.

{% hint style="info" %}
Currently, docker build is not supported in Apple Chip MacOS environment and Windows environment, and support will be provided in the future.
{% endhint %}

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

```
make USE_ROCKSDB=YES gwemix-linux
```

{% endtab %}

{% tab title="Leveldb" %}

```
make USE_ROCKSDB=NO gwemix-linux
```

{% endtab %}
{% endtabs %}

To install the `gwemix.tar.gz` binary built through Docker by copying it to the Ubuntu environment, follow the steps below.

{% tabs %}
{% tab title="Ubuntu 22.04 or 20.04.4 LTS" %}

#### Rocksdb only

```
sudo apt-get install -y libsnappy-dev libjemalloc-dev
cd /usr/lib/x86_64-linux-gnu/
sudo ln -sf libjemalloc.so.2 libjemalloc.so.1
```

#### Copy and untar "build" to $GWEMIX\_HOME

```
GWEMIX_HOME='/opt/gwemix'
sudo mkdir -p $GWEMIX_HOME 
sudo chown $USER:$USER $GWEMIX_HOME
cp build/gwemix.tar.gz $GWEMIX_HOME/
cd $GWEMIX_HOME 
tar xvzf gwemix.tar.gz
```

#### Create .rc at $GWEMIX\_HOME <a href="#create-rc-at-optnxt-2" id="create-rc-at-optnxt-2"></a>

```
PORT=8588 
DISCOVER=1        # 1 for enable discovery mode, 0 for disable discovery mode
TESTNET=1         # 1 for Testnet or remove this line for Mainnet
SYNC_MODE=full 
GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100"
```

#### Start gwemix

```
$GWEMIX_HOME/bin/gwemix.sh start
```

#### Check log

```
tail -F $GWEMIX_HOME/logs/log
```

{% endtab %}

{% tab title="Ubuntu 18.04.6 LTS" %}

#### Rocksdb only

```
sudo apt-get isntall libjemalloc1
```

#### Copy and untar "build" to $GWEMIX\_HOME

```
GWEMIX_HOME='/opt/gwemix'
sudo mkdir -p $GWEMIX_HOME 
sudo chown $USER:$USER $GWEMIX_HOME
cp build/gwemix.tar.gz $GWEMIX_HOME/
cd $GWEMIX_HOME 
tar xvzf gwemix.tar.gz
```

#### Create .rc at $GWEMIX\_HOME

```
PORT=8588 
DISCOVER=1        # 1 for enable discovery mode, 0 for disable discovery mode
TESTNET=1         # 1 for Testnet or remove this line for Mainnet
SYNC_MODE=full 
GWEMIX_OPTS="--txpool.nolocals --snapshot=false --maxpeers=100"
```

#### Start gwemix

```
$GWEMIX_HOME/bin/gwemix.sh start
```

#### Check log

```
tail -F $GWEMIX_HOME/logs/log
```

{% endtab %}
{% endtabs %}


---

# 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.wemix.com/en/install-and-operation/block-producer-node/install-guide.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.
