TRON produces a block approximately every 3 seconds, supporting high-throughput transactions and smart contract execution. TRON uses a unique resource model (Energy and Bandwidth) and Witness (Super Representative) consensus mechanism.
Schema Repository : github.com/chainstream-io/streaming_protobuf/tron
Message Types Overview
TRON Streams provides the following message types:
Message Type Description Topic TradeEvents DEX trade events tron.dex.tradesTokenEvents Token events tron.tokensBalanceEvents Balance change events tron.balancesDexPoolEvents Liquidity pool events tron.dex.poolsTransfersMessage Transfer messages tron.v1.transfers.protoCandlestickEvents Candlestick data tron.candlesticks
Block-Level Data
Field Type Description Numberuint64 Block number Hashbytes Block hash ParentHashbytes Parent block hash TimestampTimestamp Block time TxTrieRootbytes Transaction trie root Versionuint32 Block version
Field Description AddressWitness address IdWitness ID SignatureBlock signature
TRON uses DPoS consensus mechanism with 27 Super Representatives (Witnesses) taking turns to produce blocks.
Transaction-Level Data
Field Type Description Hashbytes Transaction hash Feeuint64 Transaction fee Indexuint32 Index within block ExpirationTimestamp Expiration time FeeLimituint64 Fee limit Signatures[]bytes Signature list FeePayerbytes Fee payer
Result — Execution Result
Field Description StatusExecution status SuccessWhether successful MessageError message on failure
Receipt — Resource Consumption
Field Description EnergyUsageTotalTotal Energy consumption EnergyFeeEnergy fee NetUsageBandwidth consumption NetFeeBandwidth fee
Contract
Contains contract execution details:
Field Description AddressContract address TypeContract type (TransferContract, TriggerSmartContract, etc.) ParametersCall parameters InternalTransactionsInternal transactions LogsEvent logs ExecutionTraceExecution trace WithdrawInfoReward withdrawal information
Transfer Data
TransfersMessage provides TRON chain transfer information (Topic: tron.v1.transfers.proto).
TransfersMessage Structure
message TransfersMessage {
Chain Chain = 1 ;
BlockHeader Header = 2 ;
repeated Transfer Transfers = 3 ;
}
Transfer Structure
Field Type Description CallIndexuint64 Call index LogIndexuint64 Log index Senderstring Sender address Receiverstring Receiver address Amountstring Transfer amount Idstring Token ID (NFT) URIstring Token URI CurrencyTokenInfo Token information Successbool Success status Indexuint32 Transfer index TransactionHeaderTransactionHeader Transaction header
TokenInfo Structure
Field Type Description SmartContractstring Contract address Delegatedbool Is delegated DelegatedTostring Delegation address ProtocolNamestring Protocol name Namestring Token name Symbolstring Token symbol Decimalsint32 Decimals HasURIbool Has URI Fungiblebool Is fungible AssetIdstring Asset ID (TRC-10)
TRON Token Standards
Standard Description TRC-10 TRON native tokens, no smart contract needed TRC-20 Smart contract tokens (similar to ERC-20) TRC-721 NFT tokens (similar to ERC-721)
TRC-10 is TRON’s unique native token standard, cheaper to create and transfer, but less flexible than TRC-20.
DEX Data
TradeEvents provides DEX trade data (Topic: tron.dex.trades), using common TradeEvent structure.
Trade Core Fields
Field Description token_a_address / token_b_addressTrading pair token addresses user_a_amount / user_b_amountUser trade amounts pool_addressPool address vault_a / vault_bPool vault addresses vault_a_amount / vault_b_amountVault amounts
DApp Info
Field Description program_addressDEX contract address (e.g., SunSwap) inner_program_addressInner program address chainChain identifier (CHAIN_TRON)
DexPoolEvent - Liquidity Pools
Field Description typeEvent type (INITIALIZE/INCREASE_LIQUIDITY/DECREASE_LIQUIDITY/SWAP) addressPool address token_a_address / token_b_addressToken addresses token_a_amount / token_b_amountToken amounts lp_walletLP wallet address
TRON Chain Characteristics
Energy and Bandwidth Resource Model
Unlike EVM’s Gas model, TRON uses two resources:
Resource Description How to Obtain Energy Measures smart contract execution consumption Stake TRX or pay Bandwidth (Net) Measures transaction data size consumption Stake TRX or pay
Receipt shows usage and fees for both resources:
Receipt {
EnergyUsageTotal: 50000 // Smart contract consumption
EnergyFee: 0 // 0 if staked
NetUsage: 265 // Transaction data size
NetFee: 0 // 0 if staked
}
Witness System
Characteristic Description Name Witness (Super Representative) Count 27 active Super Representatives Election Elected by token holders Block production Takes turns, ~3 seconds/block
BlockMessage contains Witness address, ID, and signature.
Predefined Contract Types
TRON predefines contract types for common operations:
Type Description TransferContractTRX transfer TransferAssetContractTRC-10 transfer TriggerSmartContractCall smart contract CreateSmartContractCreate smart contract FreezeBalanceV2ContractStake TRX UnfreezeBalanceV2ContractUnstake DelegateResourceContractResource delegation WithdrawBalanceContractWithdraw rewards
Identified through Contract’s Type field.
Resource Delegation
Users can delegate Energy and Bandwidth to other accounts, commonly used in the TRON ecosystem for:
Reducing user transaction costs
DApps paying resources for users
Topic → Message Type Mapping
Topic Proto File Message Type Description tron.dex.tradestrade_event.proto TradeEvents DEX trade events tron.dex.trades.processedtrade_event.proto TradeEvents With USD price, suspicious flag tron.tokenstoken_event.proto TokenEvents Token events tron.tokens.processedtoken_event.proto TokenEvents With description, image, social links tron.balancesbalance_event.proto BalanceEvents Balance change events tron.v1.transfers.prototron/transfers_message.proto TransfersMessage TRON transfer messages tron.v1.transfers.processed.prototron/transfers_message.proto TransfersMessage Processed transfer messages tron.dex.poolsdex_pool_event.proto DexPoolEvents Liquidity pool events tron.candlestickscandlestick.proto CandlestickEvents Candlestick data
Code Examples
Python Example: Consume TRON DEX Trades
from kafka import KafkaConsumer
from common import trade_event_pb2 # Get from streaming_protobuf repository
# Create consumer
consumer = KafkaConsumer(
'tron.dex.trades' ,
bootstrap_servers = [ '<your_broker_address>' ],
security_protocol = 'SASL_SSL' ,
sasl_mechanism = 'SCRAM-SHA-512' ,
sasl_plain_username = 'your_username' ,
sasl_plain_password = 'your_password' ,
auto_offset_reset = 'latest' ,
enable_auto_commit = False ,
group_id = 'my-tron-consumer'
)
# Consume and parse messages
for message in consumer:
trade_events = trade_event_pb2.TradeEvents()
trade_events.ParseFromString(message.value)
for event in trade_events.events:
print ( f "Pool: { event.trade.pool_address } " )
print ( f "Token A: { event.trade.token_a_address } " )
print ( f "Token B: { event.trade.token_b_address } " )
print ( f "Amount A: { event.trade.user_a_amount } " )
print ( f "Amount B: { event.trade.user_b_amount } " )
print ( f "Block: { event.block.height } " )
print ( f "DEX: { event.d_app.program_address } " )
print ( "---" )
Monitor TRC-20 Token Events
from kafka import KafkaConsumer
from common import token_event_pb2
consumer = KafkaConsumer(
'tron.tokens' ,
bootstrap_servers = [ '<your_broker_address>' ],
security_protocol = 'SASL_SSL' ,
sasl_mechanism = 'SCRAM-SHA-512' ,
sasl_plain_username = 'your_username' ,
sasl_plain_password = 'your_password' ,
auto_offset_reset = 'latest' ,
group_id = 'my-tron-token-consumer'
)
# USDT on TRON
USDT_ADDRESS = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'
for message in consumer:
token_events = token_event_pb2.TokenEvents()
token_events.ParseFromString(message.value)
for event in token_events.events:
# Filter USDT events
if event.token.address == USDT_ADDRESS :
print ( f "Event Type: { event.type } " ) # CREATED or UPDATED
print ( f "Token: { event.token.symbol } " )
print ( f "Name: { event.token.name } " )
print ( f "Decimals: { event.token.decimals } " )
print ( "---" )
Concepts & Integration Guide Kafka Streams integration basics
EVM Streams EVM chain data streams
Solana Streams Solana high-throughput data streams
WebSocket Real-time Data WebSocket integration