This guide provides a comprehensive overview of how to start a Java-tron node and interact with it using the command-line tool wallet-cli. It is assumed that Java-tron and its associated development tools are already installed on your system.
Introduction to Java-tron
Java-tron is the official Java implementation of the TRON network client. When you run Java-tron, your computer becomes a node within the decentralized TRON network. Unlike centralized systems, the TRON network operates on a peer-to-peer basis where information is shared directly between nodes. Super Representative nodes produce new blocks and broadcast them to other nodes. Each node validates incoming blocks before adding them to its local database. Java-tron updates its internal state—tracking every account's balance—using the information from these blocks.
The TRON network supports two primary account types:
- Externally Owned Accounts (EOAs): User-controlled accounts used to sign and submit transactions. Each EOA consists of a public-private key pair. The public key derives a unique address, while the private key secures the account and signs messages.
- Contract Accounts: Accounts that contain smart contract code, which is executed automatically when the account receives a transaction.
This tutorial will walk you through creating an EOA, acquiring TRX tokens, and performing a TRX transfer.
Generating a New Account
The first step to using the TRON network is generating an account. While there are several methods to create an account, this guide demonstrates the process using the wallet-cli tool.
Start the wallet-cli by running the following command in your terminal:
java -jar wallet-cli.jar- You will be greeted with a welcome message and a prompt. Type the command
registerwallet. - You will be prompted to input and confirm a password. This command generates a new TRON account and registers it within wallet-cli, which stores the private key for future transaction signing.
- Upon success, the CLI will confirm the registration and display the name of the generated keystore file.
Logging Into wallet-cli
After registering, you need to log in to manage your account.
- At the wallet prompt, enter the command
login. - You will be presented with a list of stored accounts. Select the number corresponding to your desired account.
- Enter your password. A "Login successful !!!" message confirms you are now logged in.
- Once logged in, you can view your account address using the
getaddresscommand. - It is highly recommended to back up your private key. Use the
backupwalletcommand, enter your password when prompted, and securely store the displayed private key.
Starting a Java-tron Node
A Java-tron node is required to connect to and interact with the TRON network. This guide uses the Nile testnet.
- Ensure you have the Java-tron executable JAR file.
Start the node with a command similar to the following (adjust memory parameters based on your system resources):
java -Xmx24g -XX:+UseConcMarkSweepGC -jar FullNode.jar -c nile_net_config.conf- Review the startup logs. Initial logs will display network configuration details (e.g., P2P version, IP addresses, listen port). Subsequently, logs will show the node discovering and syncing blocks from peer nodes.
To verify the node is running correctly, you can send an HTTP request to it:
curl http://127.0.0.1:16887/wallet/getnodeinfo- To check sync status, compare the block height returned by your local node's
/wallet/getnowblockendpoint with the current block height shown on a block explorer like Tronscan for the Nile testnet. If they match, your node is fully synchronized. - To gracefully shut down the node, use the command
kill -15 [process_id].
Acquiring TRX Test Tokens
To perform transactions like transfers, your account needs TRX. On the mainnet, TRX is obtained through block rewards, voting rewards, transfers from other accounts, or exchanges. On the Nile testnet, TRX holds no real value and can be acquired for free from a Faucet.
Interacting with Java-tron Using wallet-cli
Java-tron provides gRPC and HTTP interfaces. Wallet-cli is a command-line tool that uses the gRPC interface to offer a user-friendly way to interact with a node.
Checking Account Information
Use the getaccount command followed by an address to retrieve detailed information about an account, including its balance and creation time.
wallet> getaccount [address]Checking Account Balance
The getbalance command quickly displays the TRX balance (in Sun) of the currently logged-in account.
wallet> getbalanceTransferring TRX
The sendcoin command allows you to send TRX to another address.
- Use the command:
sendcoin [to_address] [amount] - The CLI will display the unsigned transaction details. Confirm the transaction by typing
y. - Select the keystore file of the account you wish to sign with.
- Enter your password to sign the transaction.
- Wallet-cli will then broadcast the signed transaction. A success message and the transaction ID (txid) will be displayed upon success.
Querying Transactions by ID
After broadcasting a transaction, you can query its details and receipt using its txid.
- Get Transaction Details:
gettransactionbyid [txid]returns the raw transaction data. - Get Transaction Receipt:
gettransactioninfobyid [txid]returns the transaction execution result, including the block number it was included in and energy usage.
👉 Explore more strategies for on-chain analysis
Interacting with Java-tron Using Curl
You can interact directly with the node's HTTP API (port 16887 by default) using tools like curl.
Checking an Account Balance
Use the wallet/getaccount endpoint to query balance information. The balance field in the response is the TRX balance in Sun.
curl -X POST http://127.0.0.1:16887/wallet/getaccount -d '{"address": "TUoHaVjx7n5xz8LwPRDckgFrDWhMhuSuJM", "visible": true}'Sending a Transaction
Sending a transaction via HTTP is a three-step process: create, sign, and broadcast.
Create an Unsigned Transaction: Use the
wallet/createtransactionendpoint to generate a transaction object.curl -X POST http://127.0.0.1:16887/wallet/createtransaction -d '{"to_address": "TUznHJfHe6gdYY7gvWmf6bNZHuPHDZtowf", "owner_address": "TUoHaVjx7n5xz8LwPRDckgFrDWhMhuSuJM", "amount": 10000000, "visible":true}'- Sign the Transaction: You must use a TRON SDK (e.g., TronWeb, java-tron SDK) or another secure method to sign the raw transaction hex (
raw_data_hex) from the previous step with the private key of theowner_address. This cannot be done with curl alone. Broadcast the Signed Transaction: Submit the signed transaction object (including the signature and
raw_data) to thewallet/broadcasttransactionendpoint.curl -X POST http://127.0.0.1:16887/wallet/broadcasttransaction -H "Content-Type: application/json" -d '{"visible": true, "signature": ["SIGNATURE_HERE"], "txID": "TXID_HERE", "raw_data": { ... }, "raw_data_hex": "RAW_HEX_HERE"}'A response with
"result": trueindicates successful broadcast.
Querying Transactions by ID
You can also query transactions using their ID via HTTP.
Get Transaction Details:
curl -X POST http://127.0.0.1:16887/wallet/gettransactionbyid -H "Content-Type: application/json" -d '{"value": "c558bd35978267d8999baf6148703cbc94786f3f2e22893637588ca05437d7f0"}'Get Transaction Receipt:
curl -X POST http://127.0.0.1:16887/wallet/gettransactioninfobyid -H "Content-Type: application/json" -d '{"value": "c558bd35978267d8999baf6148703cbc94786f3f2e22893637588ca05437d7f0"}'
Frequently Asked Questions
What is the difference between an Externally Owned Account and a Contract Account?
An Externally Owned Account (EOA) is controlled by a private key and is used to send transactions and sign messages. A Contract Account is controlled by its internal code and only activates when it receives a transaction from an EOA, executing the logic defined in its smart contract.
Why is my Java-tron node not syncing blocks?
Ensure your node has an active internet connection and the correct configuration file for the network you want to join (e.g., Nile testnet). Check the logs for connection errors. Firewall settings or network configuration might be blocking peer-to-peer communication on port 18888.
What is SUN, and how does it relate to TRX?
SUN is the smallest unit of TRX, similar to how Satoshi is to Bitcoin. 1 TRX = 1,000,000 SUN. The network often uses SUN for internal calculations and API calls to avoid decimals.
I lost my private key. Can I recover my account?
No. The private key is the ultimate proof of ownership for an account. If you lose it and haven't backed it up, there is no way to recover the assets in that account. Always store your private key and keystore file securely.
Can I use the same steps for the TRON Mainnet?
Yes, the core technical steps for running a node and interacting with it are identical. However, you must use the mainnet configuration file and acquire real TRX from an exchange to perform transactions. 👉 Get advanced methods for mainnet deployment
What does the 'net_usage' in a transaction receipt mean?Net_usage represents the Bandwidth Points consumed by the transaction. Every transaction on the TRON network consumes bandwidth, which is calculated based on the size of the transaction data. Users have a free bandwidth allowance that resets every 24 hours.