๐Ÿ”Œ Tronsell Wiki

Full Node APIs

Complete reference for TRON full node APIs. Learn how to interact with the TRON blockchain via HTTP JSON-RPC, gRPC, and event subscriptions. Includes wallet, account, contract, and transaction endpoints.

๐Ÿ”Œ API at a Glance
HTTP Endpoint /wallet, /contract
gRPC Port 50051
HTTP Port 8090
Event Subscription WebSocket / gRPC Stream
Common Methods getnowblock, getaccount, sendtransaction
Best Client TronWeb, trpc

๐Ÿ“ก Introduction to TRON Full Node APIs

A TRON full node exposes a rich set of APIs that allow developers and applications to interact with the blockchain. These APIs enable you to query blockchain data, submit transactions, deploy and interact with smart contracts, and monitor network events.

TRON nodes support three primary API interfaces:

  • HTTP JSON-RPC โ€” Simple REST-like endpoints for most operations.
  • gRPC โ€” High-performance, strongly-typed RPC using Protocol Buffers.
  • Event Streams โ€” Real-time notifications for blocks, transactions, and contract logs.
๐Ÿ“Œ Choosing an API

For most dApps and integrations, HTTP JSON-RPC is the easiest to get started with. For high-throughput or production applications, gRPC offers better performance and type safety.

๐ŸŒ HTTP JSON-RPC API

The HTTP API is served on port 8090 by default. All endpoints accept POST requests with a JSON body. The base URL is http://localhost:8090 (or your node's IP).

Common Endpoints

Endpoint Method Description
/wallet/getnowblock POST Get the current block header
/wallet/getblockbyid POST Get a block by its hash
/wallet/getblockbynum POST Get a block by its number
/wallet/getaccount POST Get account details (balance, resources)
/wallet/createtransaction POST Create a transfer transaction
/wallet/broadcasttransaction POST Broadcast a signed transaction to the network
/wallet/triggerconstantcontract POST Call a constant (view) smart contract method
/wallet/triggersmartcontract POST Execute a smart contract method (state-changing)
/contract/deploycontract POST Deploy a new smart contract

Example: Get Current Block

curl -X POST http://localhost:8090/wallet/getnowblock -H "Content-Type: application/json" -d '{}'

Example: Get Account Balance

curl -X POST http://localhost:8090/wallet/getaccount \ -H "Content-Type: application/json" \ -d '{"address": "TQ9sD9K8DkQ3XQ5XQ5XQ5XQ5XQ5XQ5XQ5"}'
๐Ÿ’ก Address Format

TRON addresses in the API are base58-encoded strings (e.g., TQ9s...). For internal operations, the node also supports hex-encoded addresses.

โšก gRPC API

TRON's gRPC API is served on port 50051 and uses Protocol Buffers for efficient, strongly-typed communication. It is the preferred interface for high-performance applications.

Key gRPC Services

  • Wallet โ€” Account info, transactions, block queries.
  • Contract โ€” Smart contract deployment and execution.
  • Network โ€” Node status, peer information.
  • Database โ€” Historical data queries (if enabled).

gRPC Example (using grpcurl)

# Get the current block via gRPC grpcurl -plaintext localhost:50051 protocol.Wallet/GetNowBlock
โšก gRPC Performance

gRPC is significantly faster than HTTP JSON-RPC for high-volume requests. It uses binary encoding and supports streaming, making it ideal for real-time applications and block explorers.

๐Ÿ“จ Event Subscriptions & WebSocket

TRON nodes support real-time event notifications via WebSocket and gRPC streams. You can subscribe to:

  • New blocks โ€” Be notified when a new block is produced.
  • Transaction events โ€” Get notified when a transaction is confirmed.
  • Contract logs โ€” Listen for events emitted by smart contracts.
  • Account updates โ€” Monitor changes to specific accounts.
# WebSocket subscription example (conceptual) ws://localhost:8090/ws/block # gRPC stream for blocks grpcurl -plaintext -d '{}' localhost:50051 protocol.Wallet/GetBlockStream
๐Ÿ“Œ Real-Time Applications

Use event subscriptions for wallets, exchanges, and monitoring tools. This is the most efficient way to stay synchronized with the network without polling.

๐Ÿ“„ Smart Contract APIs

Interacting with smart contracts is a core use case for TRON nodes. The full node provides dedicated endpoints for contract deployment, execution, and querying.

Deploy a Contract

curl -X POST http://localhost:8090/contract/deploycontract \ -H "Content-Type: application/json" \ -d '{ "owner_address": "TQ9s...", "bytecode": "60806040...", "abi": "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]", "fee_limit": 1000000 }'

Call a Contract Method

curl -X POST http://localhost:8090/wallet/triggersmartcontract \ -H "Content-Type: application/json" \ -d '{ "contract_address": "TQ9s...", "function_selector": "transfer(address,uint256)", "parameter": "000000000000000000000000...", "owner_address": "TQ9s...", "fee_limit": 1000000 }'
๐Ÿ” Contract ABI

Always provide the contract's ABI (Application Binary Interface) when interacting with smart contracts. It defines the method names, parameters, and return types.

๐Ÿ“š Client Libraries & SDKs

Several libraries simplify interaction with TRON full nodes:

๐ŸŒ
TronWeb (JavaScript/Node)

The most popular SDK for TRON. Supports HTTP and gRPC, with built-in wallet management and contract interaction.

๐Ÿ
TronPy (Python)

Python library for TRON blockchain interaction. Supports HTTP API and gRPC.

โ˜•
tron-java-sdk

Official Java SDK for TRON. Provides both HTTP and gRPC clients.

๐Ÿฆ€
tron-rs (Rust)

Community-driven Rust library for high-performance TRON applications.

TronWeb Example

// JavaScript example using TronWeb const TronWeb = require('tronweb') const tronWeb = new TronWeb({ fullHost: 'http://localhost:8090', privateKey: 'your_private_key' }) const block = await tronWeb.trx.getCurrentBlock() console.log(block)

๐Ÿ”’ API Security Best Practices

  • Restrict access โ€” Bind RPC ports to 127.0.0.1 or use a firewall to limit access to trusted IPs.
  • Use TLS โ€” For production nodes, enable TLS (HTTPS/gRPC over TLS) to encrypt traffic.
  • Rate limiting โ€” Implement request rate limiting to prevent abuse.
  • Authentication โ€” Use API keys or JWT for sensitive endpoints (custom implementation).
  • Monitor logs โ€” Watch for suspicious API activity.
๐Ÿ”‘ Production Recommendation

Never expose your full node's RPC ports directly to the public internet without authentication and rate limiting. Use a reverse proxy like nginx with TLS and auth.

โ“ Frequently Asked Questions

What is the default port for TRON HTTP API?

The default HTTP JSON-RPC port is 8090. You can change it in config.conf under node.http.port.

What is the difference between HTTP and gRPC API?

HTTP API uses JSON over REST, making it easy to use with any programming language. gRPC uses Protocol Buffers and is significantly faster, more efficient, and type-safe. gRPC also supports streaming.

How do I get the balance of a TRON address using the API?

Use the /wallet/getaccount endpoint with the address parameter. The response includes balance (in SUN, 1 TRX = 1,000,000 SUN) and resource details.

Can I subscribe to real-time events from a TRON node?

Yes, TRON nodes support WebSocket and gRPC streaming for real-time events like new blocks, transactions, and contract logs. Check your node's configuration to enable the stream service.

What is the fee limit when calling a smart contract?

The fee_limit parameter in /wallet/triggersmartcontract sets the maximum amount of TRX (in SUN) you are willing to burn for energy/bandwidth. It protects you from unexpectedly high fees.

โšก Build on TRON with Confidence

Running a full node with APIs exposed? Pair it with Tronsell Energy to power your dApps and transactions at the lowest cost.