Skip to main content
๐Ÿ“ก Tronsell Wiki

TRON API Guide โ€” Developer Reference

Complete guide to TRON APIs for developers. Learn how to interact with the TRON blockchain, query data, send transactions, and build applications using TRON's API ecosystem.

๐Ÿ“ก TRON API at a Glance
Primary LibraryTronWeb
RPC ProtocolHTTP / gRPC
Key FeaturesTransaction, Contract, Account
TestnetShasta
MainnetNile
Documentationdevelopers.tron.network

๐Ÿ“กIntroduction to TRON APIs

The TRON API provides developers with programmatic access to the TRON blockchain. Whether you're building a dApp, integrating TRON payments, or analyzing blockchain data, the TRON API ecosystem offers the tools you need.

TRON APIs are accessible via HTTP/REST and gRPC protocols. The most popular way to interact with TRON is through TronWeb, a JavaScript library that simplifies blockchain interaction.

๐Ÿ’ก Key Concept

TRON APIs are the bridge between your application and the TRON blockchain. They handle everything from querying account balances to deploying smart contracts and sending transactions.

๐Ÿ“ฆTronWeb โ€” The Primary Library

TronWeb is the official JavaScript library for interacting with the TRON blockchain. It provides a simple, intuitive interface for:

  • Account management: Create wallets, import private keys, check balances.
  • Transactions: Send TRX and TRC20 tokens (like USDT TRC20).
  • Smart contracts: Deploy and interact with TRC20 and custom contracts.
  • Blockchain queries: Get block data, transaction history, and more.
  • Resource management: Check Energy and Bandwidth, stake/unstake TRX.
๐Ÿ’ก Installation

Install TronWeb via npm: npm install tronweb or use a CDN: https://cdn.jsdelivr.net/npm/tronweb/dist/TronWeb.js

๐Ÿ”—TRON RPC Endpoints

TRON provides RPC (Remote Procedure Call) endpoints for direct blockchain interaction. Here are the main categories:

Category Endpoint Description
Account /wallet/getaccount Get account information (balance, permissions, etc.)
Transaction /wallet/createtransaction Create and send transactions
Contract /wallet/triggersmartcontract Execute smart contract functions
Block /wallet/getblock Get block information by number or ID
Node /wallet/getnodeinfo Get node status and information
Resource /wallet/getaccountresource Get account Energy and Bandwidth
๐Ÿ’ก Public Nodes

TRON provides public nodes at https://api.trongrid.io (mainnet) and https://api.shasta.trongrid.io (testnet). For production applications, consider running your own node.

๐Ÿš€Getting Started with TRON API

Here's a quick example to get you started with TronWeb:

// Import TronWeb
const TronWeb = require('tronweb');

// Connect to mainnet
const tronWeb = new TronWeb({
ย ย fullHost: 'https://api.trongrid.io',
ย ย privateKey: 'your_private_key_here'
});

// Get account balance
const balance = await tronWeb.trx.getBalance('TXXX...XXXX');
console.log('Balance:', balance / 1e6);

// Send TRX
const tx = await tronWeb.trx.sendTransaction(
ย ย 'TXYZ...XXXX',
ย ย 10 // 10 TRX
);
console.log('Transaction ID:', tx.txid);
๐Ÿ’ก Testnet First

Always test your code on Shasta testnet before deploying to mainnet. You can get free test TRX from the Shasta faucet.

๐Ÿช™TRC20 Token API

Interacting with TRC20 tokens (like USDT TRC20) is straightforward with TronWeb. Here's how to work with TRC20 contracts:

  • Contract address: USDT TRC20 is TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
  • Read functions: balanceOf(address), decimals(), symbol()
  • Write functions: transfer(to, amount), approve(spender, amount)
  • Event logs: Transfer, Approval events
// Get USDT TRC20 contract instance
const contractAddress = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';
const usdtContract = await tronWeb.contract().at(contractAddress);

// Check USDT balance
const balance = await usdtContract.balanceOf('TXXX...XXXX').call();
console.log('USDT Balance:', balance / 1e6);

// Transfer USDT
const tx = await usdtContract.transfer(
ย ย 'TXYZ...XXXX',
ย ย 100_000_000 // 100 USDT (6 decimals)
).send();
console.log('Transfer TXID:', tx.txid);
๐Ÿ’ก Decimal Handling

USDT TRC20 uses 6 decimal places. To send 100 USDT, multiply by 10^6 (100,000,000). Always check the token's decimal value before sending.

๐Ÿ“œSmart Contract API

TRON APIs support full smart contract interaction. Key functions:

  • Deploy contract: tronWeb.contract().new(...)
  • Call read function: contract.methodName(params).call() โ€” no fee, view-only
  • Execute write function: contract.methodName(params).send() โ€” requires fee (Energy/TRX)
  • Get contract info: tronWeb.trx.getContract(address)
  • Event listening: tronWeb.trx.getEventResult(contractAddress, options)
โš ๏ธ Resource Requirements

Smart contract functions (write operations) consume Energy. Ensure your account has sufficient Energy or TRX to cover the fee. Staking TRX for Energy is recommended for high-volume applications.

โœ๏ธTransaction Building

TRON APIs allow you to build and customize transactions:

  • Manual transaction creation: tronWeb.transactionBuilder.sendTrx(...)
  • Set fee limit: tronWeb.transactionBuilder.triggerSmartContract(...) with feeLimit parameter
  • Sign transaction: tronWeb.trx.sign(tx, privateKey)
  • Broadcast transaction: tronWeb.trx.sendRawTransaction(signedTx)
  • Check transaction status: tronWeb.trx.getTransactionInfo(txid)
๐Ÿ’ก Transaction Flow

The typical flow is: build โ†’ sign โ†’ broadcast โ†’ confirm. TronWeb handles most of this automatically for standard operations.

๐Ÿ’ผCommon Use Cases

๐Ÿ’ณ
Payment Integration

Accept TRX or USDT TRC20 payments. Monitor incoming transactions, confirm blocks, and automate payment processing.

๐Ÿ“Š
Analytics

Query blockchain data for analytics, reporting, and monitoring. Track transactions, balances, and contract activity.

๐Ÿค–
Automation

Automate recurring transactions, staking, and other on-chain activities using scheduled API calls.

๐Ÿ“ฑ
dApp Development

Build full-featured dApps with TronWeb, interacting with smart contracts, managing user wallets, and more.

โ“Frequently Asked Questions

What is TRON API?

TRON API is a set of interfaces that allow developers to interact with the TRON blockchain programmatically. It includes RPC endpoints for querying blockchain data, sending transactions, and interacting with smart contracts. The most common way to access TRON APIs is through TronWeb.

What is TronWeb?

TronWeb is a JavaScript library that provides a simple and intuitive interface for interacting with the TRON blockchain. It handles transaction building, signing, and broadcasting, making it the most popular tool for TRON dApp development.

How do I get started with TRON API development?

Start by installing TronWeb via npm or CDN. Connect to a TRON node (public or private), create a wallet, and start querying blockchain data. Use the official TRON documentation for detailed API references. Testnet is recommended for initial development.

Can I use TRON API to send USDT TRC20?

Yes. TRON API allows you to interact with any TRC20 smart contract, including USDT TRC20. You can call the transfer function of the USDT contract using TronWeb or directly via RPC calls. The USDT TRC20 contract address is TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t.

What are the main TRON networks for development?

TRON has two primary networks: Shasta (testnet) for development and testing, and Nile (mainnet) for production. Shasta provides free test TRX from faucets, making it ideal for building and testing applications.

โšก Save on USDT TRC20 Transfers

Integrate Tronsell Energy into your application for zero-fee USDT transfers. Simple API, instant delivery, no staking required.