> For the complete documentation index, see [llms.txt](https://validium.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://validium.gitbook.io/docs/test-and-debug/docker-l1-l2-nodes.md).

# Docker L1 - L2 Nodes

***

Welcome to this step-by-step guide on establishing a local testing environment using Docker for Validium development. With this guide, you can effortlessly emulate the Validium environment on your local system, making it simpler to test and develop features. Let's get started!

**Prerequisites**:

1. **Docker and docker-compose**: Ensure that Docker and `docker-compose` are installed on your machine. If you haven't already installed them, follow the [installation guide](https://docs.docker.com/get-docker/).
2. **ZKsync Hardhat plugins**: A foundational understanding of the ZKsync Hardhat plugins will be beneficial. New to Validium development with Hardhat? Explore the [Getting Started section](/docs/tooling/hardhat-validium/overview.md).

The `matterlabs/local-node` Docker image is currently based on the protocol `Version19` (deprecated on February 5, 2024), and it will be upgraded in the coming months. It should only be used for testing L1 <-> L2 communication.

***

### Set up the testing environment <a href="#set-up-the-testing-environment" id="set-up-the-testing-environment"></a>

1. Clone the dockerized Validium project repository to your local machine:

   ```bash
   git clone https://github.com/matter-labs/local-setup
   ```
2. To start the local node, navigate to the cloned directory:

   ```bash
   cd local-setup
   ```
3. Launch the Validium node locally using the `start.sh` script:

   ```bash
   ./start.sh
   ```

   \
   This script spins up three essential docker containers:

   1. **Postgres**: The database supporting Validium.
   2. **Local Geth node**: Acts as the Layer 1 (L1) for Validium.
   3. Validium **node**: The core component.

The first execution of the `start.sh` script should proceed without interruptions. If it halts unexpectedly, you might need to reset the local Validium state and retry. The initialization might take up to 10 minutes initially.

#### Network Details <a href="#network-details" id="network-details"></a>

* **HTTP JSON-RPC API**: Accessible via port 3050.
* **WebSocket (WS) API**: Accessible through port 3051.\
  Default endpoints:
* **L1 RPC**: [http://localhost:8545](http://localhost:8545/)
* **L2 RPC**: [http://localhost:3050](http://localhost:3050/)
* **WS API**: [http://localhost:3051](http://localhost:3051/)\
  **Network Id**: 270

***

### Reset the Validium State <a href="#reset-the-zksync-state" id="reset-the-zksync-state"></a>

If you need to revert the Validium state to its initial configuration, execute the `clear.sh` script:

```bash
./clear.sh
```

In the event of a "permission denied" error, run the following script with root access:

```bash
sudo ./clear.sh
```

***

### Pre-configured rich wallets <a href="#pre-configured-rich-wallets" id="pre-configured-rich-wallets"></a>

The Docker ZKsync environment provides test wallets with substantial ETH balances on both L1 and L2, simplifying the testing process by ensuring sufficient funds for transactions.

Rich walletsSame mnemonic rich wallets

***

### Custom configurations (advanced) <a href="#custom-configurations-advanced" id="custom-configurations-advanced"></a>

To operate with a custom Postgres database or a distinct Layer 1 node, you'll need to adjust environment variables within the `docker-compose` file:

```bash
environment:
  - DATABASE_URL=postgres://postgres@postgres/zksync_local
  - ETH_CLIENT_WEB3_URL=http://geth:8545
```

`DATABASE_URL` is the connection URL to the Postgres database, and `ETH_CLIENT_WEB3_URL` is the endpoint URL for the HTTP JSON-RPC interface of the L1 node.
