# Running Matchain Node

This guide provides instructions on launching a full node on Matchain using a simple Docker Compose script. Follow the steps below to set up your full node.

***

#### Prerequisites

**Clone the Repository**

Before starting, clone the `opstack-fullnode-sync` repository:

```bash
git clone -b v0.3.0 https://github.com/matchain/opstack-fullnode-sync.git
cd opstack-fullnode-sync
```

***

#### Recommended Hardware

* **CPU**: 4 Cores
* **RAM**: 16 GB+
* **Storage**: 1TB SSD (NVMe Recommended)
* **Network**: 100 MB/s+ Download

***

#### Preparation

1. **Generate JWT File**\
   Run the following command to generate a JWT file:

   ```bash
   openssl rand -hex 32 > jwt.txt
   ```
2. **Configure Environment Variables**\
   Copy the `.env.example` file to create your `.env` file, and update the values as needed:

   ```bash
   cp .env.example .env
   ```

   Modify `.env` to set your parameters, or request a preconfigured `.env` [file](https://github.com/matchain/node) from the Matchain team.

***

#### Operating the Node

**Start the Node**

Use Docker Compose to start the node:

```bash
docker compose --env-file .env up -d
```

**View Logs**

* **Logs for OP Node**:

  ```bash
  docker compose logs -f node
  ```
* **Logs for OP Geth**:

  ```bash
  docker compose logs -f geth
  ```

***

#### Sanity Test

**Check Sync Status**

To check the sync status, use:

```bash
curl --location 'localhost:8545' \
--header 'Content-Type: application/json' \
--data '{
  "jsonrpc": "2.0",
  "method": "eth_syncing",
  "params": [],
  "id": 2
}'
```

* If the node is still syncing, you will see output similar to:

  ```json
  {
    "jsonrpc": "2.0",
    "id": 2,
    "result": {
      "currentBlock": "0x7d0f5",
      ...
      "highestBlock": "0xd8674",
      ...
    }
  }
  ```
* When syncing completes, you will see:

  ```json
  {"jsonrpc":"2.0","id":2,"result":false}
  ```

**Check Block Number**

After syncing completes, verify by checking the latest block number:

```bash
curl --location 'localhost:8545' \
--header 'Content-Type: application/json' \
--data '{
  "jsonrpc": "2.0",
  "method": "eth_blockNumber",
  "id": 2
}'
```

* Example response:

  ```json
  {
    "jsonrpc": "2.0",
    "id": 2,
    "result": "0x2139"
  }
  ```

***

#### Stop the Node

To stop the node, use:

```bash
docker compose down
```

***

#### Reference

For further details, refer to the [Optimism Documentation](https://docs.optimism.io/builders/node-operators/tutorials/node-from-docker).


---

# 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.matchain.io/development/running-matchain-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.
