⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

TRON - Build on the High-Performance DPoS Blockchain

Chain RPC
With Dwellir, you get access to our global Chain network which always routes your API requests to the nearest available location, ensuring low latency and the fastest speeds.

Get your API key →

Why Build on TRON?

TRON is a high-performance blockchain platform designed for mass adoption with 2000+ TPS, free daily transactions, and a thriving ecosystem of DeFi, gaming, and entertainment dApps.

Unmatched Performance

  • 2000+ TPS - Process thousands of transactions per second
  • 3-second blocks - Near-instant transaction finality
  • Free transactions - Daily free bandwidth and energy for users
  • $0.000005 average fee - Ultra-low costs for paid transactions

🌍 Massive Adoption

  • 200M+ accounts - One of the largest blockchain user bases
  • 8B+ transactions - Proven scalability in production
  • $15B+ TVL - Thriving DeFi ecosystem
  • USDT dominance - 50%+ of all USDT circulates on TRON

🛠️ Developer Friendly

  • Solidity support - Deploy Ethereum smart contracts with minimal changes
  • TVM compatibility - TRON Virtual Machine based on EVM
  • Energy & Bandwidth - Unique resource model for gas optimization
  • Multi-signature - Native support for complex wallet operations

Quick Start with TRON

Connect to TRON's high-performance network with Dwellir's optimized endpoints:

🔗 RPC Endpoints

Mainnet (Chain ID: 1)Live
https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY
✓ Archive Node✓ Trace API✓ Debug API✓ WebSocket

Quick Connect:

curl -X POST https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Installation & Setup

const TronWeb = require('tronweb');

// Initialize TronWeb with Dwellir endpoint
const tronWeb = new TronWeb({
fullHost: 'https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY',
headers: { "TRON-PRO-API-KEY": 'YOUR_API_KEY' },
privateKey: 'your-private-key'
});

// Get account information
const account = await tronWeb.trx.getAccount('TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN');
console.log('Balance:', tronWeb.fromSun(account.balance), 'TRX');

// Send TRX transaction
const tx = await tronWeb.trx.sendTransaction(
'TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN',
1000000, // Amount in SUN (1 TRX = 1,000,000 SUN)
'your-private-key'
);
console.log('Transaction:', tx.txid);

Network Information

Mainnet Configuration

Address Format

TRON uses Base58 encoded addresses starting with 'T':

  • Example: TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN
  • Length: 34 characters
  • Checksum: Built-in for error detection

Core RPC Methods

Available JSON-RPC Methods

📊 Reading Blockchain Data

Query blocks, transactions, and account states

+

📤 Sending Transactions

Submit and manage transactions

+

📝 Smart Contract Interaction

Call and interact with smart contracts

+

🔧 Node & Network Info

Query node status and network information

+

Ready to integrate Base into your dApp?

Get your API key →

Account & Wallet Methods

wallet/getaccount

Get account information including balance, resources, and tokens:

const account = await fetch(`${TRON_API}/wallet/getaccount`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
address: 'TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN',
visible: true
})
});

wallet/getaccountresource

Get bandwidth and energy resources:

const resources = await fetch(`${TRON_API}/wallet/getaccountresource`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
address: 'TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN',
visible: true
})
});

Transaction Methods

wallet/createtransaction

Create a TRX transfer transaction:

const transaction = await fetch(`${TRON_API}/wallet/createtransaction`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
to_address: 'TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN',
owner_address: 'TJmmqjb1DK9TTZbQXzRQ2AuA94z4gKAPFh',
amount: 1000000, // 1 TRX in SUN
visible: true
})
});

wallet/broadcasttransaction

Broadcast a signed transaction:

const broadcast = await fetch(`${TRON_API}/wallet/broadcasttransaction`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(signedTransaction)
});

Block Methods

wallet/getnowblock

Get the latest block:

const latestBlock = await fetch(`${TRON_API}/wallet/getnowblock`);
const block = await latestBlock.json();
console.log('Block number:', block.block_header.raw_data.number);

wallet/getblock

Get block by hash or number:

const block = await fetch(`${TRON_API}/wallet/getblock`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
id_or_num: "0000000002FAB1B8", // Block hash or number
detail: true
})
});

Smart Contract Methods

wallet/triggersmartcontract

Call a smart contract function:

const contractCall = await fetch(`${TRON_API}/wallet/triggersmartcontract`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
contract_address: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', // USDT contract
function_selector: 'balanceOf(address)',
parameter: '0000000000000000000000004142b5e01c8c59a25d78acdbec2bfc7e89e5e863',
owner_address: 'TJmmqjb1DK9TTZbQXzRQ2AuA94z4gKAPFh',
visible: true
})
});

TRC20 Token Operations

Working with USDT and Other TRC20 Tokens

// TRC20 USDT Contract
const USDT_CONTRACT = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';

// Get USDT balance
async function getUSDTBalance(address) {
const { constant_result } = await tronWeb.transactionBuilder.triggerConstantContract(
USDT_CONTRACT,
'balanceOf(address)',
{},
[{type: 'address', value: address}]
);

return tronWeb.toDecimal('0x' + constant_result[0]) / 1e6;
}

// Transfer USDT
async function transferUSDT(to, amount) {
const contract = await tronWeb.contract().at(USDT_CONTRACT);
const tx = await contract.transfer(to, amount * 1e6).send();
return tx;
}
TokenContract AddressDecimals
USDTTR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t6
USDCTEkxiTehnzSmSe2XqrBj4w32RUN966rdz86
TUSDTUpMhErZL2fhh4sVNULAbNKLokS4GjC1F418
WTRXTNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR6
JSTTCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy918

Energy & Bandwidth System

Understanding TRON Resources

TRON uses a unique resource model instead of gas fees:

  1. Bandwidth Points - For normal transactions
  2. Energy - For smart contract execution
  3. TRX Fee - Fallback when resources are exhausted
// Freeze TRX for energy
async function freezeForEnergy(amount) {
const tx = await tronWeb.transactionBuilder.freezeBalance(
amount * 1e6, // Amount in SUN
3, // Duration in days
'ENERGY',
ownerAddress
);
const signed = await tronWeb.trx.sign(tx);
return await tronWeb.trx.broadcast(signed);
}

// Get account resources
async function getResources(address) {
const resources = await tronWeb.trx.getAccountResources(address);
return {
bandwidth: resources.freeNetLimit + (resources.NetLimit || 0),
energy: resources.EnergyLimit || 0,
freeTransactions: resources.freeNetUsed < resources.freeNetLimit
};
}

Resource Optimization Tips

  1. Free Transactions - Every account gets 5000 free bandwidth daily
  2. Stake TRX - Freeze TRX to get energy for smart contracts
  3. Energy Rental - Rent energy from platforms like JustLend
  4. Multi-signature - Combine resources from multiple accounts

DeFi Integration

Connecting to TRON DeFi Protocols

// JustSwap V2 Router
const JUSTSWAP_ROUTER = 'TKzxdSv2FZKQrEqkKVgp5DcwEXBEKMg2Ax';

// Swap TRX for USDT
async function swapTRXforUSDT(amountTRX) {
const contract = await tronWeb.contract().at(JUSTSWAP_ROUTER);

const path = [
'TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR', // WTRX
'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' // USDT
];

const tx = await contract.swapExactETHForTokens(
0, // Min amount out
path,
userAddress,
Date.now() + 60000 // Deadline
).send({
callValue: amountTRX * 1e6
});

return tx;
}
ProtocolCategoryTVLContract
JustLendLending$5B+Multiple contracts
SUN.ioDEX$2B+TKkeiboTkxXKJpbmVFbv4a8ov5rAfRDMf9
JustSwapAMM DEX$500M+TKzxdSv2FZKQrEqkKVgp5DcwEXBEKMg2Ax

Transaction Signing

Signing Transactions with Private Key

// Sign transaction locally
async function signTransaction(transaction, privateKey) {
const tronWeb = new TronWeb({
fullHost: 'https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY',
privateKey: privateKey
});

const signedTx = await tronWeb.trx.sign(transaction);
return signedTx;
}

// Multi-signature transaction
async function multiSigTransaction(transaction, privateKeys) {
let signedTx = transaction;

for (const key of privateKeys) {
const tronWeb = new TronWeb({
fullHost: 'https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY',
privateKey: key
});
signedTx = await tronWeb.trx.multiSign(signedTx);
}

return signedTx;
}

Best Practices

Error Handling

class TronAPIError extends Error {
constructor(message, code) {
super(message);
this.code = code;
}
}

async function safeAPICall(url, options) {
try {
const response = await fetch(url, options);
const data = await response.json();

if (data.Error) {
throw new TronAPIError(data.Error, data.code);
}

return data;
} catch (error) {
if (error.code === 'BANDWIDTH_ERROR') {
console.error('Insufficient bandwidth. Consider freezing TRX.');
} else if (error.code === 'CONTRACT_VALIDATE_ERROR') {
console.error('Smart contract validation failed.');
}
throw error;
}
}

Rate Limiting

class RateLimiter {
constructor(maxRequests = 10, interval = 1000) {
this.maxRequests = maxRequests;
this.interval = interval;
this.requests = [];
}

async throttle() {
const now = Date.now();
this.requests = this.requests.filter(time => now - time < this.interval);

if (this.requests.length >= this.maxRequests) {
const waitTime = this.interval - (now - this.requests[0]);
await new Promise(resolve => setTimeout(resolve, waitTime));
return this.throttle();
}

this.requests.push(now);
}
}

const limiter = new RateLimiter(100, 1000); // 100 requests per second

async function apiCall(endpoint, options) {
await limiter.throttle();
return fetch(endpoint, options);
}

Performance Optimization

Batch Operations

// Batch transfer to multiple addresses
async function batchTransfer(transfers) {
const transactions = [];

for (const { to, amount } of transfers) {
const tx = await tronWeb.transactionBuilder.sendTrx(
to,
amount * 1e6,
fromAddress
);
transactions.push(tx);
}

// Sign all transactions
const signedTxs = await Promise.all(
transactions.map(tx => tronWeb.trx.sign(tx))
);

// Broadcast all transactions
const results = await Promise.all(
signedTxs.map(tx => tronWeb.trx.broadcast(tx))
);

return results;
}

Caching Strategies

class TronCache {
constructor(ttl = 60000) { // 1 minute default TTL
this.cache = new Map();
this.ttl = ttl;
}

set(key, value) {
this.cache.set(key, {
value,
expiry: Date.now() + this.ttl
});
}

get(key) {
const item = this.cache.get(key);
if (!item) return null;

if (Date.now() > item.expiry) {
this.cache.delete(key);
return null;
}

return item.value;
}
}

const cache = new TronCache();

async function getCachedBalance(address) {
const cached = cache.get(`balance:${address}`);
if (cached) return cached;

const balance = await getBalance(address);
cache.set(`balance:${address}`, balance);
return balance;
}

Security Best Practices

Private Key Management

// Never expose private keys in code
const privateKey = process.env.TRON_PRIVATE_KEY;

// Use hardware wallets for production
import TronStation from 'tronstation';

async function signWithHardware(transaction) {
const tronStation = new TronStation();
const signed = await tronStation.signTransaction(transaction);
return signed;
}

// Validate addresses
function isValidTronAddress(address) {
try {
return TronWeb.isAddress(address);
} catch {
return false;
}
}

Common Use Cases

NFT Minting (TRC721)

async function mintNFT(contractAddress, recipient, tokenURI) {
const contract = await tronWeb.contract().at(contractAddress);

const tx = await contract.mint(
recipient,
tokenURI
).send({
feeLimit: 100_000_000, // 100 TRX max fee
shouldPollResponse: true
});

return tx;
}

Stablecoin Payments

async function acceptUSDTPayment(amount, memo) {
// Generate unique payment address
const paymentAddress = await generatePaymentAddress();

// Monitor for incoming USDT
const interval = setInterval(async () => {
const balance = await getUSDTBalance(paymentAddress);

if (balance >= amount) {
clearInterval(interval);
await processPayment(paymentAddress, amount, memo);
}
}, 3000); // Check every 3 seconds

return paymentAddress;
}

DAO Voting

async function castVote(proposalId, support, reason) {
const daoContract = await tronWeb.contract().at(DAO_CONTRACT);

const tx = await daoContract.castVoteWithReason(
proposalId,
support,
reason
).send({
feeLimit: 50_000_000
});

return tx;
}

Migration from Ethereum

Key Differences

FeatureEthereumTRON
Address Format0x... (hex)T... (base58)
Gas ModelETH for gasBandwidth + Energy
Block Time~12 seconds3 seconds
Free TransactionsNoYes (5000 bandwidth/day)
Native Token Decimals186

Contract Migration

// Ethereum contract
contract EthereumToken {
mapping(address => uint256) balances;

function transfer(address to, uint256 amount) public {
require(balances[msg.sender] >= amount);
balances[msg.sender] -= amount;
balances[to] += amount;
}
}

// TRON contract (minimal changes)
contract TronToken {
mapping(address => uint256) balances;

function transfer(address to, uint256 amount) public {
require(balances[msg.sender] >= amount);
balances[msg.sender] = balances[msg.sender].sub(amount);
balances[to] = balances[to].add(amount);
}
}

Support & Resources

Official Resources

Development Tools

  • TronWeb: Official JavaScript library
  • TronBox: Development framework
  • TronGrid: API service
  • TronStation: Wallet SDK

Dwellir Support

Start Building on TRON

Ready to leverage TRON's high performance and massive user base? Get started with Dwellir's optimized infrastructure:

🚀 Launch Your TRON dApp Today

Access TRON's 2000+ TPS network with enterprise-grade RPC endpoints

Get Your Free API Key →


Need help? Check our API reference or contact support.