How to Run a Tron Full Node? Easy Way

This article will guide you through the process of setting up and running a Tron full node. Whether you are a developer or a blockchain enthusiast, running a Tron full node allows you to actively participate in the Tron network, contribute to its decentralization, and access Tron node API for various purposes. We will explore two methods: using NOWNodes Tron node provider for a hassle-free experience and running a Tron full node by yourself. 

Table of Contents

    Access a Tron Full Node with NOWNodes

    NOWNodes, as a Tron node provider, allows easy and convenient access to a Tron full node without the need for extensive technical knowledge or infrastructure management instead of setting up and running a Tron full node by yourself. NOWNodes offers reliable and secure node hosting services, allowing you to focus on developing your DApps or exploring the Tron network’s capabilities.

    To get started with NOWNodes, follow these simple steps:

    • Sign up for an account on NOWNodes’ website.
    • Choose your tariff plan out of 5 available options. You can simply use the START free plan or choose any of the paid plans (PRO and higher) to access all the available shared nodes with just a single API key.
    • If you are going to use the free plan, next you will be asked to choose the 5 blockchains out of 99 available on the day of writing. Push the “ADD” button in front of the Tron (TRX) ticker as the blockchain network you want to connect to.
    • Then you need to navigate to “DASHBOARD” in your account and scroll down the page. There you will see the button “ADD NEW KEY”. Just push the button and your API key will be added automatically. This API key could be used as a Tron node API or for any other blockchains from the chosen list.
    • Open the NOWNodes postman to check all the available Tron methods.
    • Use the provided API documentation and endpoints to interact with your platform.

    NOWNodes takes care of all the technical aspects, ensuring that the Tron full node is always up and running, synchronized with the network, and accessible through their user-friendly API.

    Types of Tron Nodes

    First of all, you need to understand what kind of nodes are exist on TRON network and what’s the difference between them, to get an idea of what kind of Tron node you should use for specific Web3 development needs.

    So, there are three types of nodes on Tron’s network:

    • Witnesses nodes (Super Representatives), 
    • Full Nodes,
    • Solidity Nodes.

    Let’s take a closer look at each of them. 

    Full Nodes

    Tron Full Nodes validate incoming transactions and blocks according to the TRON network’s consensus rules. This includes checking the validity of transaction signatures, ensuring transactions aren’t double-spent, and verifying that blocks are correctly constructed. Moreover, they provide APIs that let users and developers to interact with the Tron network by utilizing JSON RPC HTTP requests.

    Archive Tron Full Nodes maintain a complete copy of the blockchain, including all the transactions and blocks. Full Nodes help in maintaining the network’s overall health and accessibility.

    Witnesses nodes (Super Representatives)

    Witness Nodes are also responsible for producing and validating blocks in the blockchain. They participate in the consensus process and are integral to the network’s security and continuity. In return for their services, SRs receive block rewards and transaction fees, incentivizing them to maintain network integrity and performance.

    Super Representatives are the elected authority nodes in the TRON network, chosen by the community through a voting system where TRX token holders can vote for their preferred candidates. SRs also have a say in the governance decisions of the TRON network, such as proposing and voting on network upgrades, changes in parameters, and other critical decisions that affect the blockchain’s future direction.

    Solidity Nodes

    Solidity Nodes synchronize irrevocable blocks and provide inquiry APIs. While Solidity Nodes also maintain a copy of the blockchain, they are particularly optimized for handling API requests and providing a fast querying service. They compile the blockchain data into a more accessible format, making it easier for developers and users to interact with the network.

    These nodes are helpful for decentralized applications (dApps) that require constant and efficient access to blockchain data. They are useful for fetching transaction histories or account balances. They provide a more efficient way to access data without overburdening the Full Nodes with read requests.

    How to Run a Tron Full Node by Yourself?

    If you prefer to have complete control over your Tron full node or have specific hardware and software requirements, you can choose to set up and run a Tron full node by yourself. Here’s how you can do it:

    Hardware Requirements

    To run a Tron full node efficiently, it is recommended to have the following hardware configuration:

    • CPU: At least 16 cores for regular full nodes and 32 cores for full nodes involved in block production.
    • RAM: A minimum of 32GB, although 64GB is recommended for block-producing nodes.
    • SSD: A storage capacity of 2.5TB or more to accommodate the blockchain data.
    • Bandwidth: A stable internet connection with at least 100Mbps download and upload speeds.

    These hardware specifications ensure smooth node operation and optimal performance.

    Software Dependencies

    Before setting up the Tron full node, make sure you have the following software dependencies installed:

    • Oracle JDK 8u211 and later: Ensure that you have Java Development Kit 8 or later installed on your system.
    • Ensure to use one of the supported Operating Systems: Linux, MacOS
    • Git: Install Git to clone the Tron source code repository and compile it if needed.

    Obtaining FullNode.jar

    To obtain the FullNode.jar file, you have two options: compiling the source code or downloading the pre-built release from the official Tron GitHub repository.

    Compiling the Source Code

    If you choose to compile the source code, follow these steps:

    • Clone the java-tron source code repository using Git:
    $ git clone https://github.com/tronprotocol/java-tron.git
    
    $ git checkout -t origin/master
    • Change your working directory to the java-tron repository and compile the code:
    $ cd java-tron
    
    $ ./gradlew clean build -x test

    Downloading the Pre-built Release

    If you prefer a quicker method, you can download the pre-built FullNode.jar file directly from the Tron GitHub releases page. Choose the version that suits your needs and download the corresponding JAR file.

    Starting the Node

    Once you have obtained the FullNode.jar file, it’s time to start your Tron full node. The process is the same regardless of whether you are running a regular full node or a block-producing full node.

    • Obtain the Tron coin mainnet configuration file, main_net_config.conf, from the official Tron deployment repository on GitHub. You can find it here.
    • Open a terminal or command prompt and navigate to the directory where the FullNode.jar file is located.
    • Start the full node with the appropriate command. For a regular full node, use the following command:
    $ java -Xmx24g -XX:+UseConcMarkSweepGC -jar FullNode.jar -c main_net_config.conf
    • The -Xmx flag specifies the maximum heap size for the Java Virtual Machine (JVM). It is recommended to set it to 80% of your available physical memory.
    • The -XX:+UseConcMarkSweepGC flag enables parallel garbage collection, improving performance.
    • If you want to run a full node that also produces blocks, add the --witness parameter to the command:
    $ java -Xmx24g -XX:+UseConcMarkSweepGC -jar FullNode.jar --witness -c main_net_config.conf
    • To participate in block production, make sure you have a super representative account and have received sufficient votes to rank within the top 27 representatives.
    • If you choose to run a block-producing full node, you need to fill in the private key of the super representative address in the localwitness list within the main_net_config.conf file. Here’s an example:
    localwitness = [
       650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812
    ]
    • Start the node with the updated configuration:
    $ java -Xmx24g -XX:+UseConcMarkSweepGC -jar FullNode.jar --witness -c main_net_config.conf
    Note: For a running full node, you can use the command kill -15 process id to shut it down gracefully.

    Additional Tips and Considerations

    How Long Does it Take to Sync a Tron Full Node?

    When starting a new Tron full node, especially for the mainnet or Nile testnet, it can take a significant amount of time to synchronize the entire blockchain. To expedite the synchronization process, you can use data snapshots. Follow these steps:

    • Download the latest data snapshot from the official Tron documentation or community resources.
    • Extract the snapshot files to the output-directory of your Tron project.
    • Start the node as usual. It will synchronize based on the data snapshot, significantly reducing the synchronization time.

    Optimizing Memory Allocation with tcmalloc

    To improve memory allocation performance in the java-tron codebase, you can utilize tcmalloc. Here’s how to optimize memory allocation with tcmalloc:

    • Install tcmalloc on your system. The installation process varies depending on your Linux distribution.
    • Ubuntu 20.04 LTS / Ubuntu 18.04 LTS / Debian stable:
    $ sudo apt install libgoogle-perftools4
    • Ubuntu 16.04 LTS:
    $ sudo apt install libgoogle-perftools4
    • CentOS 7:
    $ sudo yum install gperftools-libs
    • Add the following lines to your startup script, modifying the path to tcmalloc according to your Linux distribution:
    #!/bin/bash
    
    export LD_PRELOAD="/usr/lib/libtcmalloc.so.4"
    export TCMALLOC_RELEASE_RATE=10
    
    # Original start command
    java -jar .....

    This optimization technique can enhance the memory allocation efficiency of your Tron full node.

    Conclusion

    Running a Tron full node opens up numerous possibilities for developers and blockchain enthusiasts. Whether you choose to set up and manage your own node or utilize the NOWNodes’ Tron node API, you can actively participate in the Tron network and contribute to its decentralization. Follow the steps mentioned in this guide to get started and become an integral part of the Tron ecosystem.

    Take advantage of the resources available and embark on your journey with NOWNodes into Tron full nodes today.