XDC Subnet Setup: A Detailed Walkthrough

Explore the most recent upgradable guide document.

Vinn
3 min readFeb 10, 2024

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/

1. Create a Folder for XDC Subnet Setup

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

mkdir XDCSubnet

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

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

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

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

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.

To access the commands.txt file:

nano commands.txt

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

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

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

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.

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

8. Access the Subnet UI

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

--

--