In the rapidly evolving landscape of blockchain technology, staying ahead of the curve is essential. One of the most intriguing advancements in the world of blockchain is the concept of blockchain subnets. In this comprehensive guide, we will dive deep into what blockchain subnets are, how they work, and why they are becoming a game-changer in the blockchain industry.
What Are Blockchain Subnets?
Blockchain subnets are like specialized branches of a blockchain network. They allow you to create smaller, independent networks within a larger blockchain ecosystem. Think of them as self-contained mini-blockchains, each with its own unique features and functionalities. These subnets operate alongside the main blockchain but offer more flexibility and scalability.
How Do Blockchain Subnets Work?
Blockchain subnets work by segregating the main blockchain into smaller, more manageable parts. This segmentation brings several advantages such as Scalability, Customization, Privacy and Security.
Setting Up Your Own Blockchain Subnet
XDC Subnet is a powerful technology that allows you to create a secure, scalable, and decentralized network within the XDC Ecosystem. It enables various use cases, including creating private subnets, deploying decentralized applications (DApps), and more. In this guide, weβll walk you through the steps to set up your own XDC Subnet, opening doors to a world of possibilities.
Step 1: Uninstall Old Versions
Before you dive into setting up XDC Subnet, ensure that you donβt have any conflicting packages from previous installations. Run the following command to uninstall them:
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
Step 2: Set Up the Docker Repository
To install Docker Engine, you need to set up the Docker repository. Follow these steps:
- Update the apt package index and install required packages:
$ sudo apt-get update
$ sudo apt-get install ca-certificates curl gnupg
- Add Dockerβs official GPG key:
$ sudo install -m 0755 -d /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg - dearmor -o /etc/apt/keyrings/docker.gpg
$ sudo chmod a+r /etc/apt/keyrings/docker.gpg
- Use the following command to set up the repository:
$ echo \
"deb [arch="$(dpkg - print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Update the apt package index again:
$ sudo apt-get update
Step 3: Install Docker Engine
- Now, you can install Docker Engine, containerd, and Docker Compose by running the following command:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Verify the installation by running:
$ sudo docker run hello-world
- Update the apt package index & Test the installation.
$ sudo apt-get update
$ docker compose version
Your Docker installation will be successfully completed using these steps!
With Docker set up, letβs move on to setting up XDC Subnet.
Step 4: Clone the Subnet Repository
Clone the Subnet repository and change the directory:
git clone https://github.com/XinFinOrg/XinFin-Node.git
cd XinFin-Node/subnet/deployment-generator/
Step 5: Create a Docker Environment File
Create a docker.env file with parameters similar to docker.env.example, & make necessary configurations by entering below command.
cp docker.env.example docker.env
Below is an example of the minimum file required for configs generation, Update the below parameters with your data in the docker.env file. Refer to check out in detail Config Explanation.
- To check out exact config path, enter the following command:
pwd
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.
docekr.env file:
#deployment config
CONFIG_PATH= /XinFin-Node/subnet/deployment-generator
#subnet config
NETWORK_NAME=testsubnet
NUM_SUBNET=1
NUM_MACHINE=3
MAIN_IP=192.168.1.1
#parentchain config
PARENTCHAIN=devnet
PARENTCHAIN_WALLET=0x0000000000000000000000000000000000000000
PARENTCHAIN_WALLET_PK=0x0000000000000000000000000000000000000000000000000000000000000000
Step 6: Pull the Latest Subnet Generator Image
Pull the latest Subnet Generator image with this command:
sudo docker pull xinfinorg/subnet-generator:latest
Step 7: Generate Configurations
Generate configurations, this will create a new generated directory.
docker run --env-file docker.env -v $(pwd)/generated:/app/generated xinfinorg/subnet-generator:latest && cd generated
Follow the generated instructions in commands.txt to start Subnet Nodes and make sure they are mining.
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
Step 8: Deploy the Checkpoint Smart Contract
Again, follow the generated instructions in commands.txt to deploy the Checkpoint Smart Contract to the βdeployment-generatorβ folder.
Run βcd..β command to get back to the βdeployment-generatorβ folder.
cd ~/.XinFin-Node/subnet/deployment-generator
docker run --env-file docker.env \
-v $(pwd)/generated/deployment.json:/app/generated/deployment.json \
--entrypoint 'bash' xinfinorg/subnet-generator:latest ./deploy_csc.sh
Execute the following command to deploy the Checkpoint Smart Contract:
This will provide you with the Checkpoint Smart Contract address (checkpoint deployed to:)
Step 9: Deploy Subnet Services
Follow the instructions in commands.txt to deploy Subnet Services (relayer, stats-server, frontend) to the βdeployment-generator/generatedβ folder:
cd ~/.XinFin-Node/subnet/deployment-generator/generated
docker compose --env-file docker-compose.env --profile services pull
docker compose --env-file docker-compose.env --profile services up -d
Step 10: Check the Status
docker ps -a
Step 11: Explore the Subnet UI
Finally, explore the Subnet UI by accessing it at :5000.
Congratulations! Youβve successfully set up your XDC Subnet, enabling you to harness the full potential of XDC Networkβs blockchain technology.
Checkout the guide for XDC Subnet user interface.
Some Common Issues and Solutions:
Issue 1: Finding the Systemβs IP Address
Question: If I do not have the private IP, where can I find the IP address of my system?
Answer: To determine your systemβs IP address, use the following command:
ip a
Issue 2: Locating the Checkpoint Smart Contract Address
Question: Where can I find the checkpoint smart contract address?
Answer: After executing the command below, you will obtain the βcheckpoint smart contract address.β Please consult the βcommand.txtβ file for the necessary commands.
cd ~/.XinFin-Node/subnet/deployment-generator
docker run - env-file docker.env \
-v $(pwd)/generated/deployment.json:/app/generated/deployment.json \
- entrypoint 'bash' xinfinorg/subnet-generator:latest ./deploy_csc.sh
Issue 3: Resolving βNo Such File or Directoryβ Errors
Question: What should I do if I encounter the βno such file or directoryβ error repeatedly?
Answer: To address this, execute the command below to generate new configuration files. This will create a new directory to replace the existing one. Once you have the new directory, follow the subsequent steps as outlined in the βcommand.txtβ file.
docker run - env-file docker.env -v $(pwd)/generated:/app/generated xinfinorg/subnet-generator:latest && cd generated
Issue 4: Determining the Exact Config Path for βdocker.envβ
Question: How can I find the exact configuration path to update in the βdocker.envβ file?
Answer: To obtain the precise configuration path, use the βpwdβ command, which will provide you with the necessary information.
pwd
Issue 5: Troubleshooting 'CSC Deployment Failed' Issue: Checkpoint Smart Contract Deployment
Question: Encountering a "CSC deployment failed" issue during the deployment of the Checkpoint Smart Contract?
Answer: Please verify that the provided Private Key contains sufficient funds for both the Smart Contract deployment and subsequent transactions.
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.
Blockchain subnets represent a new frontier in blockchain technology. They offer the scalability, customization, and security needed to drive innovation across various industries. As blockchain subnets continue to gain momentum, staying informed about their capabilities and potential applications is crucial for anyone involved in blockchain development or adoption.
If you have any questions or need assistance, donβt hesitate to reach out to the XDC Network community on XDC.Dev. Start your XDC Subnet journey today!
Discussion (5)
I am encountering an issue while configuring my custom subnet. When I execute the "deploy checkpoint smart contract" command as specified in the commands.txt file, I receive an error message.
I've come across a configuration issue with my XDC subnet. Following the instructions in the commands.txt file, when I attempt to execute the 'deploy checkpoint smart contract' command, I encounter an error message stating 'could not detect the network.'
Please refer below screenshot:
the issue is resolved thank you
how did you resolve it?
How do I set up an rpc url?
For future readers, may I reference your separate post regarding the same issue.
xdc.dev/gaslimit/how-do-i-get-an-r...