Skip to main content
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 TypeDescriptionTopic
TradeEventsDEX trade eventstron.dex.trades
TokenEventsToken eventstron.tokens
BalanceEventsBalance change eventstron.balances
DexPoolEventsLiquidity pool eventstron.dex.pools
TransfersMessageTransfer messagestron.v1.transfers.proto
CandlestickEventsCandlestick datatron.candlesticks

Block-Level Data

BlockHeader Core Fields

FieldTypeDescription
Numberuint64Block number
HashbytesBlock hash
ParentHashbytesParent block hash
TimestampTimestampBlock time
TxTrieRootbytesTransaction trie root
Versionuint32Block version

Witness (Super Representative) Information

FieldDescription
AddressWitness address
IdWitness ID
SignatureBlock signature
TRON uses DPoS consensus mechanism with 27 Super Representatives (Witnesses) taking turns to produce blocks.

Transaction-Level Data

TransactionHeader

FieldTypeDescription
HashbytesTransaction hash
Feeuint64Transaction fee
Indexuint32Index within block
ExpirationTimestampExpiration time
FeeLimituint64Fee limit
Signatures[]bytesSignature list
FeePayerbytesFee payer

Result — Execution Result

FieldDescription
StatusExecution status
SuccessWhether successful
MessageError message on failure

Receipt — Resource Consumption

FieldDescription
EnergyUsageTotalTotal Energy consumption
EnergyFeeEnergy fee
NetUsageBandwidth consumption
NetFeeBandwidth fee

Contract

Contains contract execution details:
FieldDescription
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

FieldTypeDescription
CallIndexuint64Call index
LogIndexuint64Log index
SenderstringSender address
ReceiverstringReceiver address
AmountstringTransfer amount
IdstringToken ID (NFT)
URIstringToken URI
CurrencyTokenInfoToken information
SuccessboolSuccess status
Indexuint32Transfer index
TransactionHeaderTransactionHeaderTransaction header

TokenInfo Structure

FieldTypeDescription
SmartContractstringContract address
DelegatedboolIs delegated
DelegatedTostringDelegation address
ProtocolNamestringProtocol name
NamestringToken name
SymbolstringToken symbol
Decimalsint32Decimals
HasURIboolHas URI
FungibleboolIs fungible
AssetIdstringAsset ID (TRC-10)

TRON Token Standards

StandardDescription
TRC-10TRON native tokens, no smart contract needed
TRC-20Smart contract tokens (similar to ERC-20)
TRC-721NFT 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

FieldDescription
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

FieldDescription
program_addressDEX contract address (e.g., SunSwap)
inner_program_addressInner program address
chainChain identifier (CHAIN_TRON)

DexPoolEvent - Liquidity Pools

FieldDescription
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:
ResourceDescriptionHow to Obtain
EnergyMeasures smart contract execution consumptionStake TRX or pay
Bandwidth (Net)Measures transaction data size consumptionStake 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

CharacteristicDescription
NameWitness (Super Representative)
Count27 active Super Representatives
ElectionElected by token holders
Block productionTakes turns, ~3 seconds/block
BlockMessage contains Witness address, ID, and signature.

Predefined Contract Types

TRON predefines contract types for common operations:
TypeDescription
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

TopicProto FileMessage TypeDescription
tron.dex.tradestrade_event.protoTradeEventsDEX trade events
tron.dex.trades.processedtrade_event.protoTradeEventsWith USD price, suspicious flag
tron.tokenstoken_event.protoTokenEventsToken events
tron.tokens.processedtoken_event.protoTokenEventsWith description, image, social links
tron.balancesbalance_event.protoBalanceEventsBalance change events
tron.v1.transfers.prototron/transfers_message.protoTransfersMessageTRON transfer messages
tron.v1.transfers.processed.prototron/transfers_message.protoTransfersMessageProcessed transfer messages
tron.dex.poolsdex_pool_event.protoDexPoolEventsLiquidity pool events
tron.candlestickscandlestick.protoCandlestickEventsCandlestick 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("---")