0Chain
Search…
Step 2: Setup the network for 0Chain components

Get the Magic Block

A magic block file contains miners and sharders values that will be used for further 0Chain network operations. It is important to get the magic block from the chain you want to connect and update the magic_block.json file.
Let's get the magic block from the 0chain directory and update the magic_block.json file in the 0dns directory.
1
cp 0chain/docker.local/config/b0magicBlock_4_miners_1_sharder.json 0dns/docker.local/config/magic_block.json
Copied!

Build and Configure 0dns

0dns service is responsible for connecting to the network and fetching all the magic blocks from the network, which are saved in the DB. 1.Navigate to 0dns directory
1
cd 0dns
Copied!
2.Open the 0dns configuration file(0dns.yaml) using the nano editor.
1
nano docker.local/config/0dns.yaml
Copied!
3.Disable both use_https and use_path (set them to false).This is required to fix the miner and sharder URLs so they work locally.
4.Save the changes and run the following command inside the 0dns directory
1
./docker.local/bin/build.sh
Copied!
Here is the screenshot of the console after a successful build

Set up a Docker Network

To create sharder, blobber, miner containers and allow interaction between them. You need to create a network using Docker, which connects them with each other.
  1. 1.
    To set up a network go to the 0chain directory
    1
    cd 0chain
    Copied!
  2. 2.
    Run the setup network script
    1
    docker.local/bin/setup_network.sh
    Copied!
    On successful Setup, you will receive a network ID in response :
    1
    d9c238b3f21899137c905b13a4c52fbcab46bee4527d0b6525031c3401b4d329
    Copied!

Start the 0dns container

To connect to the test network we just created and to fetch all the magic blocks. Run the 0dns container.
1.Navigate to 0dns directory
1
cd 0dns
Copied!
2.Run the start script as (sudo or root) using the command.
1
./docker.local/bin/start.sh
Copied!
Here is the screenshot of the output after a successful start.