๐ก 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.
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
Example: Get Account Balance
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)
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.
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
Call a Contract Method
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:
The most popular SDK for TRON. Supports HTTP and gRPC, with built-in wallet management and contract interaction.
Python library for TRON blockchain interaction. Supports HTTP API and gRPC.
Official Java SDK for TRON. Provides both HTTP and gRPC clients.
Community-driven Rust library for high-performance TRON applications.
TronWeb Example
๐ 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.
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.