# Configure Erigon

Erigon is by default an "[all-in-one](https://docs.erigon.tech/erigon/v2/basic-usage/usage#all-in-one-client)" binary solution, but it's possible start any internal component as a separated processes:

* [RPCDaemon](https://docs.erigon.tech/erigon/v2/advanced-usage/rpc-daemon), the JSON RPC layer
* [TxPool](https://docs.erigon.tech/erigon/v2/advanced-usage/txpool), the transaction pool
* [Sentry](https://docs.erigon.tech/erigon/v2/advanced-usage/sentry), the p2p layer
* [Downloader](https://docs.erigon.tech/erigon/v2/advanced-usage/downloader), the history download layer

This may be for security, scalability, decentralisation, resource limitation, custom implementation, or any other reason you/your team deems appropriate. See the appropriate section to understand how to start each service separately.

{% hint style="info" %}
**Hint:** Don't start services as separated processes unless you have clear reason for it.
{% endhint %}

## Using TOML or YAML Config Files

You can set Erigon flags via a YAML or TOML configuration file with the flag `--config.` The flags set in the configuration file can be overridden by writing the flags directly to the Erigon command line.

### YAML

Assuming we have `--chain=mainnet` in our configuration file, adding `--chain=holesky` will override the flag inside the yaml configuration file and set the chain to Holesky.

```
./build/bin/erigon --config ./config.yaml --chain=holesky
```

**Example of setting up a YAML config file**

```
datadir : 'your datadir'
chain : "mainnet"
http : true

http.api : ["eth","debug","net"]
```

### TOML

**Example of setting up TOML config file**

```
datadir = 'your datadir'
chain = "mainnet"
http = true

"http.api" = ["eth","debug","net"]
```

## Building new developments

{% hint style="warning" %}
**Warning**: for advanced users only.
{% endhint %}

For building the bleeding edge development branch:

<pre><code><strong>git clone --recurse-submodules https://github.com/erigontech/erigon.git
</strong>cd erigon
git checkout devel
make erigon
</code></pre>

You can check the [list of releases](https://github.com/ledgerwatch/erigon/releases) for release notes.

Increase download speed by flag `--torrent.download.rate=20mb`. (see [Downloader](https://docs.erigon.tech/erigon/v2/advanced-usage/downloader))

Use `--datadir` to choose where to store data.

Use `--chain=gnosis` for [Gnosis Chain](https://www.gnosis.io/), `--chain=bor-mainnet` for Polygon Mainnet, and `--chain=mumbai` for Polygon Mumbai. For Gnosis Chain you need a [Consensus Layer](https://github.com/ledgerwatch/erigon#beacon-chain-consensus-layer) client alongside Erigon (<https://docs.gnosischain.com/node/guide/beacon>).

Running `make help` will list and describe the convenience commands available in the [Makefile](https://github.com/ledgerwatch/erigon/blob/devel/Makefile).

## Datadir structure

* `chaindata`: recent blocks, state, recent state history. low-latency disk recommended.
* `snapshots`: old blocks, old state history. can symlink/mount it to cheaper disk. mostly immutable. Must have \~100GB of free space (to merge recent files into a larger one).
* `temp`: can grow to \~100GB, but usually empty. can symlink/mount it to cheaper disk.
* `txpool`: pending transactions. safe to remove.
* `nodes`: p2p peers. safe to remove.

Note that the `--datadir` option that allows you to store Erigon files in a non-default location, in this example, in the `holesky` subdirectory of the current directory. The name of the directory `--datadir` does not have to match the name of the chain in `--chain`.

```
./build/bin/erigon --datadir=/holesky
```

## Logging

Flags:

* `verbosity`
* `log.console.verbosity` (overriding alias for `verbosity`)
* `log.json`
* `log.console.json` (alias for `log.json`)
* `log.dir.path`
* `log.dir.prefix`
* `log.dir.verbosity`
* `log.dir.json`

In order to log only to the stdout/stderr the `--verbosity` (or `log.console.verbosity`) flag can be used to supply an int value specifying the highest output log level:

```
  LvlCrit = 0
  LvlError = 1
  LvlWarn = 2
  LvlInfo = 3
  LvlDebug = 4
  LvlTrace = 5
```

To specify an output directory for the logs to be collected on disk, please set `--log.dir.path` If you want to change the filename produced by `erigon` you should also set the `--log.dir.prefix` flag to an alternate name. The `--log.dir.verbosity` flag is also available to control the verbosity of this logging, with the same int value as above, or the string value e.g. ' debug' or 'info'. The default verbosity is 'debug' (4), for disk logging.

The log format can be set to json by using the boolean flags `log.json` or `log.console.json`, or for the disk output `--log.dir.json`.

## Multiple Instances / One Machine

The following 6 flags must be defined to avoid conflicts:  `--datadir --port --http.port --authrpc.port --torrent.port --private.api.addr`.

Example of multiple chains on the same machine:

{% code overflow="wrap" %}

```
# mainnet
./build/bin/erigon --datadir="<your_mainnet_data_path>" --chain=mainnet --port=30303 --http.port=8545 --authrpc.port=8551 --torrent.port=42069 --private.api.addr=127.0.0.1:9090 --http --ws --http.api=eth,debug,net,trace,web3,erigon

# sepolia
./build/bin/erigon --datadir="<your_sepolia_data_path>" --chain=sepolia --port=30304 --http.port=8546 --authrpc.port=8552 --torrent.port=42068 --private.api.addr=127.0.0.1:9091 --http --ws --http.api=eth,debug,net,trace,web3,erigon
```

{% endcode %}

Quote your path if it has spaces.

## Dev Chain

The Erigon development mode sets up a private, instantly-mined test blockchain to rapidly prototype and test Ethereum applications and modifications without risk.

You can find a detailed explanation on how to run a local Dev Chain [here](https://github.com/ledgerwatch/erigon/blob/devel/DEV_CHAIN.md).
