Connect to the TRON network
Connect to a TRON node through a public HTTP endpoint or your own self-hosted full node, using TronWeb (JavaScript) or Trident (Java).
Prerequisites
When developing on TRON, the first step is to establish a connection to the network. Several infrastructure providers offer the nodes and APIs your applications need to send transactions, query on-chain data, and interact with smart contracts. This page covers the standard connection patterns.
HTTP endpoints from TronGrid
TronGrid is the most widely used infrastructure provider in the TRON ecosystem, offering free, high-performance node services — powering on-chain read/write traffic for a large number of wallets, exchanges, and DApps. The HTTP endpoints below cover Mainnet and the public testnets:
| Network | Full node HTTP endpoint |
|---|---|
| Mainnet | https://api.trongrid.io |
| Shasta testnet | https://api.shasta.trongrid.io |
| Nile testnet | https://nile.trongrid.io |
| Local node | http://127.0.0.1:8090 or http://localhost:8090 |
Connecting from JavaScript (TronWeb)
TronWeb is the primary JavaScript SDK for TRON. It works in browsers, Node.js, and IoT environments, and exposes TRON's transaction-building, signing, and broadcasting flow. For full reference, see the TronWeb documentation.
const { TronWeb } = require('tronweb');
const tronWeb = new TronWeb({
fullHost: 'https://api.trongrid.io',
// Shasta testnet: https://api.shasta.trongrid.io
// Nile testnet: https://nile.trongrid.io
headers: { 'TRON-PRO-API-KEY': 'YOUR_API_KEY' }, // only required for Mainnet
privateKey: 'your private key'
});The TRON-PRO-API-KEY header is required for customized Mainnet usage. Get one from the TronGrid dashboard.
Connecting from Java (Trident)
Trident is a lightweight Java SDK for TRON. It supports offline address generation, offline transaction signing, and full-node HTTP and gRPC APIs. For full reference, see the Trident documentation.
import org.tron.trident.core.ApiWrapper;
// Shasta testnet
ApiWrapper wrapperShasta = ApiWrapper.ofShasta("YOUR_PRIVATE_KEY_HERE");
// Nile testnet
ApiWrapper wrapperNile = ApiWrapper.ofNile("YOUR_PRIVATE_KEY_HERE");
// Mainnet
ApiWrapper wrapperMainnet = ApiWrapper.ofMainnet("YOUR_PRIVATE_KEY_HERE", "YOUR_API_KEY_HERE");
// Custom FullNode and SolidityNode gRPC endpoints
String privateKey = System.getenv("TRON_PRIVATE_KEY");
ApiWrapper wrapperCustom = new ApiWrapper(
"your-custom-fullnode:50051",
"your-custom-solidity-node:50061",
privateKey
);Public nodes vs self-hosted nodes
TRON provides access to public nodes managed by community infrastructure providers, allowing you to interact with the blockchain without the overhead of maintaining your own hardware. While these public endpoints are an ideal starting point for initial development and testing, production-grade applications should eventually transition to a private node or a reputable third-party infrastructure provider. This shift ensures a more secure, high-performance environment fully tailored to your application's specific requirements. For a complete list of endpoints and details on rate limits, refer to the Networks documentation.
For developers requiring maximum control, privacy, or dedicated performance, hosting a private TRON node is the optimal solution. A self-hosted node provides total authority over data synchronization, custom indexing, and outbound network configurations. To begin your deployment,see Nodes and clients.
Related resources
- Getting testnet tokens — request free TRX before sending your first transaction
- Send your first transaction — end-to-end TRX transfer using the TronWeb endpoint above
- Sign and broadcast via raw HTTP — what TronWeb does under the hood
Updated 6 days ago