Skip to main content
참고: 이 페이지는 아직 한국어로 번역되지 않았습니다. 아래는 영어 원문입니다.

Introduction

Here, we’ll installing and running a local instance of Quai Network in a containerized environment. The local network instance contains one full node, one CPU miner for each of the 9 shards, and multiple accounts with pre-loaded Quai and Qi balance. The containerized local network instance is designed to provide an easily configurable, low overhead development environment for builders.

Install Dependencies

To run a local instance of Quai Network, you’ll need to install a few dependencies.
1

Install Docker Compose

There are two methods to install Docker Compose:
  1. Install Docker Desktop, which bundles Docker Compose. (recommended)
  2. Install the Docker Compose plugin via CLI.
If you’re unsure which method is best for you, visit the Installing Docker Compose page for more information.
2

Install Local Node Runner

To install the Local Node Runner, you’ll need to clone the quai-local-node repository and navigate to it.

Run Local Instance

Now that we’ve installed Docker Compose and navigated to the quai-local-node repository, we can run the local network instance.

Start

To start the local network instance in a Docker container, run:
bash docker-compose up -d
After running this command, you’ll see each of the processes start up. One go-quai container, and 9 instances of quai-cpu-miner (one for each shard) should initialize like so:

View Logs

To view the logs for the go-quai container from your terminal, run:
If you’d like to access logs for a specific shard, you’ll need to navigate to the quai-local-node-go-quai-1 container and print logs directly.

Stop

If your local network instance is running in the background, run the following command to stop:
If your local network instance is running in the foreground, you can exit the terminal or use CTRL+C to stop the container.

Custom Network Configuration

The below configuration section is only necessary for running non-default configurations. If you only want to run the default network configuration of 9 slices and miners, you can skip this section.
The quai-local-node is configured to run all 9 shards (slices) and a CPU miner for each shard by default. It is recommended to run the default configuration for most use-cases. If you want to run a custom slice configuration, the section below details how to do so. To alter the default local network configuration, you’ll need to:
  • Edit the slices the local node is running in the config.toml file
  • Edit the number of CPU miners to match the number of shards in the docker-compose.yml file
1

Configure Slices

To start slice configuration, open the node config file with a text editor:
Inside of this directory is the config.toml file. The config file has a slices variable with a default value of all 9 slices.
Edit the slices variable to match the number of shards you want to run. For example, if you want to run 3 shards, you could set the slices variable to [0 0],[0 1],[0 2].
2

Configure CPU Miners

To edit the CPU miner config, you’ll need to edit the docker-compose.yml file. Open the docker-compose.yml file with a text editor:
Each of the miner instances in the config file has a replica variable that defaults to 1. If this value is set to 1, a miner for that chain will be spun up on start, if the value is set to 0 the miner will not be spun up on start.
We need to ensure that a CPU miner is spun up (replica is set to 1) for each of the slices we configured in the node above. For example, if we’re running slices [0 0],[0 1],[0 2], we need to set the replica value for the cyprus1, cyprus2, and cyprus3 miners to 1 and all the others to 0.
After matching the slices the node is running to the CPU miner configurations, you can start up your custom local network instance.

Interacting With The Local Network

To interact with the local network instance, you can use the Quais SDK or JSON RPC API. The network is accesible via specific networking ports on localhost.

SDK

You can use the Quais SDK to create a provider connected to your local network instance and get chain data and send transactions.

JSON RPC API

You can make requests to your local network using the JSON RPC API and cURL:

Accounts

The local network we just spun up starts with a number of accounts pre-loaded with Quai and Qi tokens for each shard. A full list of accounts with pre-loaded balances, sorted by shard and ledger, can be found in the genallocs directory of the quai-local-node repository.
These accounts are for local testing purposes and should not be used in any production environment. They are not secure and should only be used for testing.
For quick reference, 1 account for each shard and ledger can be found below:

Quai Accounts

Qi Accounts