Developers Forum for XinFin XDC Network

Vinn
Vinn

Posted on • Updated on

[Informative] XDC Subnet Setup: A Detailed Walkthrough

Setting up an XDC Subnet allows you to create a customized blockchain network that interoperates with the XDC Network. Follow these steps to set up your XDC Subnet efficiently.

Requirements:

  • OS: Linux. Only Linux is supported for full deployment.

  • OS: Mac is only supported for single machine testing environment. Specify MacOS with ‘OS=mac’ in ‘docker.env’ file. Please also refer common issues.

  • Docker, Docker compose V2. For manual installation of docker compose V2 please refer to: https://docs.docker.com/compose/install/linux/

Step1: Create a Folder for XDC Subnet Setup

Use the following command to create a folder for setting up the XDC Subnet:

mkdir XDCSubnet
Enter fullscreen mode Exit fullscreen mode

Step 2: Create the docker.env File

Create a docker.env file with parameters similar to “docker.env.example”. Access the docker.env file with the command:

nano docker.env
Enter fullscreen mode Exit fullscreen mode

Copy the content below into the file, save it by pressing “Y” and then “Enter”.

  • If you don’t have any private key, You can create it using XDC Beta Web wallet or else you can use XDCPay.
  • For Devnet XDC, you can visit XDC Devnet Faucet.
  • Please verify that the provided Private Key contains sufficient funds for both the Smart Contract deployment and subsequent transactions.
#subnet config
NETWORK_NAME=localsubnet
NUM_MACHINE=1
NUM_SUBNET=3
MAIN_IP=192.168.1.1

#parentchain config
PARENTNET=devnet
PARENTNET_WALLET_PK=0x1111111111111111111111111111111111111111111111111111111111111111

# OS=mac
#docker image versions, default to stable
# VERSION_SUBNET
# VERSION_BOOTNODE
# VERSION_RELAYER
# VERSION_STATS
# VERSION_FRONTEND
Enter fullscreen mode Exit fullscreen mode

Step 3: Pull the generator.sh Script

Retrieve the generator.sh script from the generator GitHub repository using the command:

curl -O https://raw.githubusercontent.com/XinFinOrg/XinFin-Node/master/subnet/deployment-generator/script/generate.sh
Enter fullscreen mode Exit fullscreen mode

Step 4: Generate Configurations

Make the generate.sh script executable and run it to generate configurations, creating a new ‘generated’ directory:

chmod +x generate.sh
./generate.sh
cd generated
Enter fullscreen mode Exit fullscreen mode

Step 5: Start Subnet Nodes

Follow the instructions provided in the ‘commands.txt’ file within the ‘generated’ directory to start Subnet Nodes and ensure they are mining. For detailed steps, refer to the Subnet Nodes Debug Guide.

To see the list of all files, utilize the “ls" command.
Image description

To access the commands.txt file:

nano commands.txt
Enter fullscreen mode Exit fullscreen mode

Note: Make sure you are referring to your “commands.txt” file for further deployment.

Deploy Subnet on machine1:

docker compose - env-file docker-compose.env - profile machine1 pull
docker compose - env-file docker-compose.env - profile machine1 up -d
Enter fullscreen mode Exit fullscreen mode

In any case, if the nodes might not be peering you can try RESET the Subnet:

docker compose - env-file docker-compose.env - profile machine1 down
rm -r bootnodes
rm -r xdcchain*
docker compose - env-file docker-compose.env - profile machine1 up -d
Enter fullscreen mode Exit fullscreen mode

Step 6: Deploy the Checkpoint Smart Contract (CSC)

Continue following the instructions in ‘commands.txt’ to deploy the upgradable Checkpoint Smart Contract.

docker run --env-file common.env   \
    -v $(pwd)/../generated/:/app/config       \
    --network host                             \
    --entrypoint './docker/deploy_proxy.sh' xinfinorg/csc:v0.1.1
Enter fullscreen mode Exit fullscreen mode

Upon successful deployment, you should find CSC addresses in the ‘common.env’ file.

Additional environment variables, including PROXY_GATEWAY, FULL_CSC, LITE_CSC, and CHECKPOINT_CONTRACT, will be added.

Step 7: Start Subnet Services

Follow the instructions in ‘commands.txt’ to start Subnet Services such as the relayer, stats-server, and frontend.

docker compose - env-file docker-compose.env - profile services pull
docker compose - env-file docker-compose.env - profile services up -d
Enter fullscreen mode Exit fullscreen mode

Step 8: Access the Subnet UI

Access the Subnet UI at :5000 to explore and interact with your XDC Subnet.

Image description

Checkout the guide for "How to Connect the Metamask to Subnet".

Discussion (0)