# Compile and Run

## Download

Pull source code from `git`

```shell
git clone https://github.com/DxChainNetwork/dxc.git
```

## Install Golang

Reference: <https://go.dev/doc/install>

```bash
// or in linux:
$ sudo snap install go --classic
```

## Compile

```bash
$ cd /path/to/dxc
$ make geth
```

The compiled geth executable file is under the /path/to/dxc/build/bin path.

Run `./build/bin/geth --help` to get instruction, or refer to [command-line-options](https://geth.ethereum.org/docs/interface/command-line-options).

## Run

### Run Configuration&#x20;

* Access the working directory `/directory/of/geth`
* Create `config.toml`in the working directory

```toml
[Eth]
SyncMode = "snap"
TrieCleanCacheRejournal= 300000000000

[Eth.Miner]
GasFloor = 0
GasCeil = 40000000
GasPrice = 1000000000
Recommit = 3000000000
Noverify = false

[Node]
InsecureUnlockAllowed = true
IPCPath = "geth.ipc"
```

> Default to use `SyncMode = "snap"` for the node snyc mode, for the full node sync is `SyncMode = "full"`

* Create`start.sh` in the working directory

```bash
#!/bin/bash

set -e

# DXC_DIR the path of geth
DXC_DIR=/directory/of/geth

cd $DXC_DIR

# --datadir ./data Blockchain data storage directory
nohup ./geth --datadir ./data --config ./config.toml --verbosity 3 >>./data/system.log 2>&1 &
```

### Run Node

```shell
$ /bin/bash start.sh
```

## Network

The node program starts as `mainnet` by default, add the `--testnet` command at runtime if you want to start the testnet.
