Developers Forum for XinFin XDC Network

ruslan wing
ruslan wing

Posted on

Setting Up an RPC Node Server for Your DApp on XDC Network: A Comprehensive Guide

A dedicated RPC (Remote Procedure Call) on the XDC network refers to an RPC server that is exclusively used by a specific DApp or application rather than shared by multiple clients.

When a DApp or application needs to interact with the Ethereum network, it typically sends requests to an RPC server, communicating with a node on the Ethereum network to execute the requested action or retrieve information. In a shared RPC server environment, multiple DApps or applications send requests to the same server, potentially causing congestion and slowdowns.

By contrast, a dedicated RPC server is set up specifically for a particular DApp or application, providing its own dedicated resources and eliminating the potential for congestion from other clients. This can result in faster response times and more reliable performance, which can be important for high-traffic or mission-critical applications.

Setting up a dedicated RPC server typically involves setting up a full node on the XDC network, configuring it to enable RPC communication, and opening the necessary ports to allow external access to the server. Once the server is set up, the DApp or application can configure its connection to the dedicated RPC server to begin interacting with the XDC network.

Overall, a dedicated RPC server can be a valuable tool for DApps or applications that require high performance and reliability in their interactions with the XDC network.

XDC Network is a high-performance blockchain designed for enterprise-grade applications. If you’re building a decentralized application (DApp) on the XDC Network, you must set up a full node and a dedicated RPC server to interact with the network.

This comprehensive guide will walk you through a step-by-step process of setting up a full node and a dedicated RPC server for your DApp on the XDC Network.

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

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

Step:-1 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

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

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.

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

Discussion (5)

Collapse
redpill1 profile image
samsam

Great post @ruslan_wing Thanks.
What are the ports for TLS/SSL? As far as I understand 8989 and 8888 are non-TLS/SSL ports. If you could add some pointers that would be great, because anyway we shouldn't be using non-TLS channel for security and privacy.

Also, related question. I have seen posting saying you need to keep few ports (3030x) to get better peer rate, but I am running node for 2-3 months now, and all ports are intentionally blocked from outside-in, but peers have been as good as for most of the best nodes at 18 peers.
Again from security stand-point, if it can get equally good peer numbers, should the recommendation instead be to secure the network by not opening unnecessary ports. Thoughts?

Collapse
olukayode_simeon_cede787c profile image
Olukayode Simeon

I need a working xdc rpc

Collapse
ruslan_wing profile image
ruslan wing Author

Please check out the working RPC on Main-Net and Apothem Network

Main-Net
rpc.xinfin.network/
erpc.xinfin.network/
rpc.xdcrpc.com/
erpc.xdcrpc.com/

Apothem Network
rpc.apothem.network/
erpc.apothem.network/
apothem.xdcrpc.com/

Collapse
11ppm profile image
11ppm

Thank you so much for the wonderful guide. I had resigned myself to the fact that it would take a week for synchronization, but now I know it's normal. I'll refer to this guide next time I set things up. Thanks again.

Collapse
11ppm profile image
11ppm

I set up a full node yesterday and used a snapshot to synchronize quickly. However, I noticed that the number of peers is smaller than before. Previously, I was able to connect to around 15-18 peers immediately. Why is this happening?