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:
- Install Docker Desktop, which bundles Docker Compose. (recommended)
- Install the Docker Compose plugin via CLI.
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
View Logs
To view the logs for thego-quai
container from your terminal, run:
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: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.
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 Edit the
config.toml
file. The config file has a slices
variable with a default value of all 9 slices.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 Each of the miner instances in the config file has a We need to ensure that a CPU miner is spun up (
docker-compose.yml
file. Open the docker-compose.yml
file with a text editor: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.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
.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 onlocalhost
.
Shard | HTTP Port | WS Port |
---|---|---|
Prime | 9001 | 8001 |
Cyprus | 9002 | 8002 |
Paxos | 9003 | 8003 |
Hydra | 9004 | 8004 |
Cyprus 1 | 9200 | 8200 |
Cyprus 2 | 9201 | 8201 |
Cyprus 3 | 9202 | 8202 |
Paxos 1 | 9220 | 8220 |
Paxos 2 | 9221 | 8221 |
Paxos 3 | 9222 | 8222 |
Hydra 1 | 9240 | 8240 |
Hydra 2 | 9241 | 8241 |
Hydra 3 | 9242 | 8242 |
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.
Quai Accounts
Shard | Address | Private Key | Balance |
---|---|---|---|
Cyprus1 | 0x000001273B55E9e5998328216dB1b130c231221C | 0xb3c87ca9645adcf75be5c4d6609fd257f897fd53849c7ecca81acae9966a6ec0 | 10000 Quai |
Cyprus2 | 0x010001D025371794a6eDb5feE8aC2F384EdD7463 | 0xcea8ebb619f8e4ea11ee75cb72221a6f39591a99d7cf688de9f30832809fb751 | 10000 Quai |
Cyprus3 | 0x02000415996A1B0cFF4b2FD078c779cF6C3E9AaC | 0xfc86fae56f462d2ae43bca8f819b1137c9e3150ba3ff79d4d5068b6e39c1c975 | 10000 Quai |
Paxos1 | 0x10000197Ec7c3e6ce4D9a832c0641528c5e268A6 | 0x01d872f0bc5f94490c2ed9026d58a116656dcb3c997f42062d01799e5b458062 | 10000 Quai |
Paxos2 | 0x11000207A6723c18085c12F50F62929bb78932c4 | 0x1d7a3a668ac8b20bf538a6d1060de043f10b1db5f1df2140fa0e8d479820e763 | 10000 Quai |
Paxos3 | 0x120000833E752B14A00eBB2c00eF0FD7C90C2123 | 0xc0061e94c526e7d9d97a2874f129e72e4f821a8f78ca2fd8198c005bc14e2a92 | 10000 Quai |
Hydra1 | 0x2000011eCb5FDEA6Eb074cbe60b6Ad372948d99a | 0xc77fb4c5b1612f702ef097561f75ee5876987ef547977020a86528fbc9f7bbbc | 10000 Quai |
Hydra2 | 0x2100042dEf9D880e029Ca948f97C180c202bd743 | 0x44af4c54c44d96bbf3d9c602967822246381d2287fe544fd5480d05b25b80bb9 | 10000 Quai |
Hydra3 | 0x2200035A5A89846AD708d8732B6c85dFAbE35489 | 0x8cd878d69b1b848b3c98c623e4e56e3b0ed1035984f6f721a99ef716637e3382 | 10000 Quai |
Qi Accounts
Shard | Address | Private Key | Balance |
---|---|---|---|
Cyprus1 | 0x0080038f1C9a96b196914939301F9a46d7E27e7E | 0x5b18d340e2e5172a90dfcc43c800519cf4a77b82750b8964b3f421dc929eac53 | 100000 Qi |
Cyprus2 | 0x01800Daf0f10f7d0CceF2B77893d5a7f86D6D406 | 0x4500c9cef91ac29479cf50a00c49d27ba14e84df83b8e332db34fa1cbdd799b7 | 100000 Qi |
Cyprus3 | 0x02800a7c404409166D903Dd3421595112f1DaF4D | 0xbc144acdd4d53488e4005d404f42450a879eb1015a6f4bbf80956b4810b5a068 | 100000 Qi |
Paxos1 | 0x1080049337283F6c3aDfD535835258a03CF2b921 | 0x511930ce12cbf86325eb2652459b6a47b75ddc892a09549f094f0011062a11f4 | 100000 Qi |
Paxos2 | 0x1180008531658Aa78161D00689267725C771aD3d | 0x89086104efd789c7de9ee69beb44ad70818a772a90b6d3f3ec26da930a47a2da | 100000 Qi |
Paxos3 | 0x12800163E05c66e107864D9c18067468cf79990f | 0xa7995e0942e6510a2fd3461c0dbe081fc8e79c6e891fd2fcde5897e41700789a | 100000 Qi |
Hydra1 | 0x208000B3ED3a21D2018E72533D55679760C7a8d2 | 0x36f009591733e706085ba4b6c3c6bbc8e35fa5e9f075979650523c18f18dacec | 100000 Qi |
Hydra2 | 0x218000a39174Db63f0047DC571CB2279d6D29434 | 0xf07d9c6d2ee5cd1f5661d87afea21cd21e4a52ff1ea4851b7507b4ef673c4311 | 100000 Qi |
Hydra3 | 0x228003fD91A5B55dBAfc95384e3A8DBf30B21AA8 | 0x2c1b28175b12d8fdeb8355918fcb7492fcbc7b118ecf301cd928477815084312 | 100000 Qi |