# Run a Chiliz Chain Node

Running your own Chiliz Chain node offers enhanced control, privacy, and reliability, but requires more technical expertise and resources compared to using an existing RPC endpoint.

It allows you to transact and communicate with smart contracts on the Chiliz Chain

{% hint style="info" %}
Note that there's a Validator-specific node-running documentation page: [Running a Validator node](/learn/about-validators/running-a-validator-node.md)
{% endhint %}

## **Prerequisites**

To run the Chiliz Chain node, you must have [Docker](https://www.docker.com/) installed, either on your machine or your server. Therefore, please complete the [Docker installation](https://docs.docker.com/engine/install/) before you proceed.

### **Pre-built Docker images**

You can use the pre-built Docker images from the [Chiliz Chain 2.0 public repository on the Docker hub](https://hub.docker.com/repository/docker/chilizchain/ccv2-geth).

## **Launch a node and start the sync**

The recommended starting point to run a Chiliz Chain node is with the mounted data volume. If this method is used to recreate a Docker container, the data gets stored in the directory and can easily be reused or cloned to another node.

### **Step 1: Create a Directory**

Create a directory and point to it in the `-v` parameter in the following command:

```bash
docker run \
-v $(pwd)/my-datadir:/datadir \
--name ccv2-node \
-p 8545:8545 \
-p 8546:8546 \
chilizchain/ccv2-geth:latest \
--chiliz # for Chiliz Mainnet. Use --spicy for Spicy Testnet.
--datadir=/datadir \
--ipcdisable
```

### **Step 2: Connect Client**

To connect a client with a node, you must enable RPC HTTP and/or the WebSocket servers by specifying `--http` and/or `--ws` parameter groups respectively.

For example:

```bash
docker run \
-v $(pwd)/my-datadir:/datadir \
--name ccv2-node \
-p 8545:8545 \
-p 8546:8546 \
chilizchain/ccv2-geth:latest \
--chiliz \ # for Chiliz Mainnet. Use --spicy for Spicy Testnet.
--datadir=/datadir \
--ipcdisable \
--http \
--http.addr=0.0.0.0 \
--http.api=eth,net,web3,debug,txpool \
--http.port=8545 \
--http.corsdomain="*" \
--http.vhosts="*" \
--ws \
--ws.addr=0.0.0.0 \
--ws.api=eth,net,web3,debug,txpool \
--ws.port=8546 \
--ws.origins="*" \
```

{% hint style="warning" %}
**CAUTION**

For security reasons, ensure you set appropriate values for the following parameters:

`--http.corsdomain`

`--http.vhosts`

`--ws.origins`
{% endhint %}

## **Node Maintenance Information**

### Change verbosity when debugging

​In some cases, you may want to increase the verbosity of the node, i.e. when you must debug either the node or the connecting client itself.

To do that, you can define a `--verbosity` parameter. It can accept the following options (default is 3):

* 0=silent
* 1=error
* 2=warn
* 3=info
* 4=debug
* 5=detail

### Stop the node and clean up

If you have launched the node using one of the above commands then your node process continues to run in the foreground. To stop this process, press CTRL+C.

Run the following command to remove the Docker container:

```bash
docker rm ccv2-node
```

### **Delete the directory**

Run the following command to delete a directory:

```bash
rm my-datadir
```

## Updating your Node

The Chiliz Chain team strives to keep Chiliz Chain secure and modern, and we will therefore make hard fork now and then every year, such as the Dragon8 hard fork.

In the event of a hard fork, your node will be out of sync with the network. It is therefore important to follow our announcements, and update your node.

To keep your node updated, you can follow the following steps.

**If you use Docker:**

1. Ensure you stop and delete your existing Docker container while preserving the volumes that contain your database.
2. Launch your node using [the latest pre-built Docker image available](https://hub.docker.com/repository/docker/chilizchain/ccv2-geth).

**If you use your own binary:**

1. [Download the latest release from our GitHub repository](https://github.com/chiliz-chain/v2/releases).
2. Build from there with your toolset.

## Running an archive node

To run a node in archive mode, you should add the following 2 parameters into the `ccv2-geth` call presented above:

```bash
--syncmode=full \
--gcmode=archive \
```

## Running a Chiliz Chain Node from a Snapshot or Backup

To speed up the synchronization process of your Chiliz Chain node, you can rely on a snapshot — a recent copy (or archive/backup) of the blockchain data directory (`datadir`). This method allows your node to become operational more quickly compared to syncing from scratch.

{% hint style="info" %}
It recommend to keep snapshots for new node setups.\
Overwriting an existing datadir with a snapshot may lead to inconsistencies.
{% endhint %}

### Available Snapshots

Each network has a dedicated snapshot:

* Spicy Testnet: [chaindata\_snapshot.tar.gz](https://s3.eu-west-3.amazonaws.com/spicy-snapshots.chiliz.com/chaindata_snapshot.tar.gz)
* Chiliz Chain Mainnet: [chaindata\_snapshot.tar.gz](https://s3.eu-west-3.amazonaws.com/snapshots.chiliz.com/chaindata_snapshot.tar.gz)

{% hint style="info" %}
**Cleaning Existing Data**

If you intend to apply a snapshot to an existing node, ensure you delete the following directories and files within your datadir before restarting the node:

```bash
rm -rf blobpool transactions.rlp LOCK lightchaindata triecache
```

This step helps prevent potential conflicts arising from residual data.
{% endhint %}

### Steps to Run a Node from a Snapshot:

1. Create a Data Directory:

```bash
mkdir -p ~/chiliz-node/my-datadir
```

2. Download the Snapshot:

Replace the URL with the Mainnet snapshot URL if needed.

{% code overflow="wrap" lineNumbers="true" %}

```bash
cd ~/chiliz-node/my-datadir
nohup curl -L --retry 5 -o chaindata.tar.gz https://s3.eu-west-3.amazonaws.com/spicy-snapshots.chiliz.com/chaindata_snapshot.tar.gz > download.log 2>&1 &
```

{% endcode %}

{% hint style="info" %}
To monitor the download progress, use:\
`tail -f download.log`
{% endhint %}

3. Extract the Snapshot:

```bash
tar -xzf chaindata.tar.gz
```

4. Run the Chiliz Chain Node:

{% code lineNumbers="true" %}

```bash
docker run \
  -v ~/chiliz-node/my-datadir:/datadir \
  --name ccv2-node \
  -p 8545:8545 \
  -p 8546:8546 \
  chilizchain/ccv2-geth:latest \
  --spicy \  # Use --chiliz for Mainnet
  --datadir=/datadir \
  --ipcdisable \
  --http \
  --http.addr=0.0.0.0 \
  --http.api=eth,net,web3,debug,txpool \
  --http.port=8545 \
  --http.corsdomain="*" \
  --http.vhosts="*" \
  --ws \
  --ws.addr=0.0.0.0 \
  --ws.api=eth,net,web3,debug,txpool \
  --ws.port=8546 \
  --ws.origins="*"
```

{% endcode %}

## Additional Geth information

Visit Geth's [command-line options](https://geth.ethereum.org/docs/fundamentals/command-line-options) to view the full list of available Geth parameters.


---

# 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.chiliz.com/develop/basics/connect-to-chiliz-chain/run-a-chiliz-chain-node.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.
