Developers Forum for XinFin XDC Network

Cover image for Everything You Need to Know to Set Up an RPC Node Server on XDC Network.
Lucas Chua
Lucas Chua

Posted on

Everything You Need to Know to Set Up an RPC Node Server on XDC Network.

Are you looking to set up an RPC node server on the XDC network? If so, you've come to the right place. In this step-by-step guide, we'll walk you through the process of setting up your own node server on the XDC network. As you may already know, the XDC network is a blockchain network designed for enterprise use cases. It offers high transaction throughput, low latency, and robust security features. By setting up your own node server on the XDC network, you'll be able to validate transactions, participate in governance, and earn rewards.

Before getting started with steps to setup RPC nodes, let's understand What is XDC Network? And what RPC Node Server is?, why it is so important for a blockchain network and Dapps development.

What is XDC Network?

The XinFin XDC Network is an open-source, carbon-neutral, enterprise-grade, EVM-compatible, Layer 1 blockchain that has been operationally successful since 2019. The network obtains consensus via a specially delegated proof-of-stake (XDPoS) technique that allows for 2-second transaction times, near-zero gas expenses ($0.00001), over 2000 TPS, and interoperability with ISO 20022 financial messaging standards. The XDC Network powers a wide range of novel blockchain use cases that are secure, scalable, and highly efficient.

RPC Node Server Explained in Simple Words.

A blockchain network needs RPC servers as a crucial component. Requests from users and other servers must be received, processed, and validated by them. Distributed applications (Dapps) that operate on the blockchain can be made by developers using RPC nodes, enabling users to communicate with the network in a secure and trustless way.

Developers can send transactions, perform smart contracts, and retrieve data on the blockchain using RPC nodes. Additionally, they offer a means for programmers to communicate with the underlying blockchain technology without having to create a lot of complicated code. The creation and deployment of Dapps is made simpler for coders as a result.

The blockchain's consensus algorithm is upheld by RPC servers, which are also used to verify transactions. Without them, there would be a higher risk of attack and manipulation on the blockchain network.

Advantages of Using RPC Node

Using RPC nodes to develop Dapps on XDC Network provides developers with several benefits.

  • RPC nodes allow developers to access the blockchain’s data without having to write complex code. This makes it easier for developers to create and deploy Dapps with minimal effort.
  • Using RPC nodes also ensures that the Dapps created on XDC Network are highly scalable. This is because the nodes are able to quickly process requests and validate transactions on the blockchain. This makes it easier for developers to create and deploy applications that are able to handle a large amount of traffic.
    RPC (Remote Procedure Call) nodes provide a number of benefits for development and deployment, including:

  • Improved performance: By offloading computationally expensive tasks to remote nodes, RPC can improve the performance and responsiveness of your application.

  • Scalability: RPC allows you to scale your application horizontally by adding more nodes to your network as needed, which can help accommodate increased traffic and demand.

  • Distributed architecture: RPC enables a distributed architecture, allowing you to deploy your application across multiple nodes and locations, which can improve fault tolerance and reduce downtime.

  • Language-agnostic: RPC allows you to use different programming languages for different parts of your application, making it easier to leverage the strengths of each language and avoid language limitations.

  • Encapsulation of complexity: RPC provides an abstraction layer that encapsulates the complexity of remote communication, making it easier to build and maintain your application.

  • Security: RPC can help improve security by limiting access to sensitive data and resources, and by providing secure communication channels between nodes.

  • Interoperability: RPC allows different applications to communicate with each other regardless of the underlying technology or platform, making it easier to integrate with other systems and services.
    Finally, using RPC nodes to develop Dapps on XDC Network allows developers to take advantage of the network’s low transaction fees. This makes it easier for developers to create and deploy applications that are cost-effective and efficient.

Let's get started and take the first step towards becoming a part of the XDC network!

Learn How to set up an RPC node.

Before we get started, make sure you have the following prerequisites:

  1. A server or cloud instance with at least 16 GB of RAM and 500 GB of storage.
  2. Ubuntu 20.04 LTS operating system.
  3. Basic knowledge of the Linux command line.

Let’s get started with the steps to set up the RPC node.
Step1: Setting up the full node with the Bootstrap command.

sudo su -c “bash <(wget -qO- https://raw.githubusercontent.com/XinFinOrg/XinFin-Node/master/setup/bootstrap.sh)" root
Enter fullscreen mode Exit fullscreen mode

For Example:-

$ sudo su -c “bash <(wget -qO- https://raw.githubusercontent.com/XinFinOrg/XinFin-Node/master/setup/bootstrap.sh)" root
[sudo] password for user: 
Please enter your XinFin Network (mainnet/testnet/devnet) :- mainnet
Your running network is mainnet
Please enter your XinFin MasterNode Name :- Demo_Server 
Your Masternode Name is Demo_Server
Enter fullscreen mode Exit fullscreen mode

Step 2: Setting up the full node with docker
Clone repository

git clone https://github.com/XinFinOrg/XinFin-Node.git
Enter fullscreen mode Exit fullscreen mode

Enter XinFin-Node directory

cd XinFin-Node
Enter fullscreen mode Exit fullscreen mode

Install docker & docker-compose

sudo ./setup/install_docker.sh
Enter fullscreen mode Exit fullscreen mode

Update the .env file with details Create a .env file by using the sample — .env.example

Enter either your company or product name in the INSTANCE_NAME field.

Enter your email address in the CONTACT_DETAILS field.

cd mainnet # testnet
cp env.example .env
nano .env
Enter fullscreen mode Exit fullscreen mode

Start your Node

cd mainnet
sudo docker-compose -f docker-compose.yml up -d
Enter fullscreen mode Exit fullscreen mode

To stop the node, or if you encounter, any issues use

sudo docker-compose -f docker-compose.yml down
Enter fullscreen mode Exit fullscreen mode

Attach XDC Console:

cd mainnet
sudo bash xdc-attach.sh
Enter fullscreen mode Exit fullscreen mode

You can check the status of your full node on the stats page at https://stats1.xinfin.network, and if you want your full node to get sync faster, you can download the latest snapshot from https://download.xinfin.network/xdcchain.tar

Follow the snapshot steps to get your full node to sync faster

  1. sudo docker-compose -f docker-compose.yml down
  2. wget https://download.xinfin.network/xdcchain.tar
  3. tar -xvzf xdcchain.tar
  4. rm -rf xdcchain/XDC
  5. mv XDC xdcchain/XDC
  6. sudo docker-compose -f docker-compose.yml up -d

After downloading the snapshot, monitor your node on the stats page. Once your node is fully synced, you can start using the dedicated RPC for your Dapp. Please note that the RPC port used is 8989, and for WebSocket, the port used is 8888.

To enable the 0x prefix RPC Endpoint, you can add the flag “ — enable-0x-prefix” to your “startnode.sh” script. This will allow the RPC Endpoint to recognize and process 0x-prefixed addresses.

Once the RPC node is set up and connected to the XDC Network, developers can start building their own Dapps.

Here are a few articles for your reference to get you started with Smartcontract deployment on XDC Network.

How to create and deploy a smart contract with Hardhat on XDC Network- Developers Forum for XinFin XDC Network 🌱

How to deploy smart contracts using Foundry on XDC Network ! - Developers Forum for XinFin XDC Network 🌱

How to deploy a smart contract using Vyper on XDC Network! Developers Forum for XinFin XDC Network 🌱

How to Deploy a smart contract with XinFin Remix IDE by connecting Metamask through D'CENT Wallet Software App. - Developers Forum for XinFin XDC Network 🌱

Multiple ways to upgrade a Solidity smart contract deployed on XDC Network! Developers Forum for XinFin XDC Network 🌱

Checking XDC Network Smart Contracts for Vulnerabilities Using Mythril: A Step-by-Step Guide. - Developers Forum for XinFin XDC Network 🌱

Using RPC nodes to develop Dapps on XDC Network allows developers to take advantage of the network’s low transaction fees. This makes it easier for developers to create and deploy applications that are cost-effective and efficient.

So, if you are looking to develop powerful Dapps on XDC Network, make sure to take advantage of the power of RPC nodes. By following the steps outlined in this article, you will be able to set up an RPC node and create your own Dapp on XDC Network.

If you have any questions / queries, please post them on https://xdc.dev

Discussion (2)

Collapse
redpill1 profile image
samsam

Hi @lucas_chua_ebd1d8d9e09f30

How long does step 3 using snapshot is suppose to take? Because that tar extract (tar -xvzf xdcchain.tar ) is taking almost 2 hours now on very good machine, still running through output showing ..
....
XDC/chaindata/1711752.ldb
XDC/chaindata/1711753.ldb
XDC/chaindata/1711754.ldb
XDC/chaindata/1711756.ldb
....

Collapse
redpill1 profile image
samsam • Edited on

Never mind, it finished just now after about 2 hours.