Event subscription

Four ways to receive TRON on-chain events — TronGrid HTTPS, TronWeb, the Fullnode's built-in ZeroMQ publisher, or self-hosted plugins (Kafka / MongoDB) — plus the V1.0 / V2.0 event service framework and the seven event trigger types.

📘

Prerequisites: Deploy a node — only required for the self-hosted methods

A TRON Fullnode produces a continuous stream of on-chain activity — every block, every transaction, every smart-contract log. Event subscription is the mechanism by which an application receives that stream. There are multiple ways to access it, depending on how much infrastructure you want to operate and whether you need historical backfill in addition to real-time push.

How to access events

MethodBest forOperates locally?Historical backfill
TronGrid (hosted HTTPS query)Front-ends, lightweight integrationsNo — managed serviceYes (queryable by tx / block)
TronWeb (JavaScript SDK)Browser and Node.js appsNo — wraps TronGridYes (Mainnet + testnets; private chains not supported)
Built-in ZeroMQ (Fullnode publisher)Dev work, a single in-network consumerYes — needs a FullnodeYes — with Event Service Framework V2.0 enabled, historical events can be published starting at a specified block height
Self-hosted plugin (Kafka / MongoDB)Indexers, analytics pipelines, durable streamsYes — needs a Fullnode + plugin + storageYes — with Event Service Framework V2.0 enabled, historical events can be published starting at a specified block height

The first two require no infrastructure beyond what your application already runs. The last two require operating a TRON Fullnode but give you direct access to the event stream without provider rate limits.

  • TronGrid — see Get events by transaction ID and TronGrid V1 API overview. TronGrid formats event-plugin data as extension APIs and exposes them through hosted HTTPS endpoints.
  • TronWeb — JavaScript SDK with built-in event helpers. See the TronWeb event API. Works on Mainnet and testnets; not available for private chains.
  • Built-in ZeroMQ — TRON Fullnodes ship a built-in ZeroMQ publisher (TIP-28), so no plugin install is needed. See ZeroMQ event plugin.
  • Self-hosted plugins — durable transports backed by Kafka or MongoDB. The rest of this page focuses on these.

Event service framework

The Fullnode's event service framework reads and packages on-chain events, then passes them to the built-in ZeroMQ publisher or an external plugin. Two framework versions exist; the choice affects whether historical backfill is available.

VersionReal-time pushesHistorical backfillDefault
V1.0Yes — events fire as new blocks are processedNo — only events produced from the moment the node startsYes (when event.subscribe.version is unset)
V2.0YesYes — events from a configured starting height are replayed before the live streamOpt-in via event.subscribe.version = 1

V2.0 was introduced to let indexers bootstrap from a specific historical block rather than only follow the chain head. For deeper background and version-selection guidance, see the Event service framework V2.0 introduction.

Migrating V1.0 → V2.0

Switching from V1.0 to V2.0 primarily involves configuration changes. The built-in ZeroMQ publisher requires no external plugin installation or upgrade.

  1. Update the plugin (Kafka / MongoDB only). V2.0 historical sync can produce high-volume bursts; older plugin builds may run out of memory. Download the latest from event-plugin releases or build from source:

    git clone https://github.com/tronprotocol/event-plugin.git
    cd event-plugin
    ./gradlew build
  2. Enable V2.0 in config.conf:

    event.subscribe.version = 1
  3. Retain your subscription configuration. Switching framework versions does not require changes to topics or filter. For ZeroMQ, retain the native configuration. For external plugins, retain connection settings such as server and dbconfig, and update path to point to the new package after upgrading.

  4. (Optional) Configure historical backfill start height:

    event.subscribe.startSyncBlockNum = <block_height>
    • startSyncBlockNum <= 0 — backfill disabled; behavior matches V1.0 real-time.
    • startSyncBlockNum > 0 — backfill enabled; events from that height are replayed before the live stream starts.
  5. Set event.subscribe.enable = true in config.conf, then restart the Fullnode. Historical events replay first, then the live stream takes over.

🚧

Verify startSyncBlockNum before restart.

A height below your consumer's last-seen point produces duplicates; a height above produces gaps. This is the most common source of post-migration data inconsistencies.


Event types

A Fullnode emits seven trigger types. Each can be independently enabled in the plugin's topics block. The triggerName values are fixed identifiers; only the consumer-side topic name (Kafka topic or MongoDB collection) is customizable.

Configuration: topics[].triggerNameEvent message contentsTypical use
blockNewly produced block headersBlock-height monitors, head trackers
transactionTransactions included in blocks processed by the nodeTransaction and resource-cost indexers
contracteventDecoded contract events (parsed against ABI)Application back-ends consuming events as structured records
contractlogRaw contract logs (topics + data)DeFi indexers, NFT trackers handling raw logs
solidityMost recent solidified block heightExchanges, bridges — anything needing finality before acting
solidityeventDecoded contract events on solidified blocksSame as contractevent but post-finality
soliditylogRaw contract logs on solidified blocksSame as contractlog but post-finality

With contractParse = true (the default), logs that can be decoded against the ABI go to contractevent / solidityevent; other logs go to contractlog / soliditylog. Each trigger type must be enabled separately. To receive the complete raw log stream, set enable = true and redundancy = true in the relevant contractlog or soliditylog entry so that decoded events also produce a raw log copy.

📘

Event subscription resource cost

Subscribing to many trigger types simultaneously raises the Fullnode's CPU and memory cost. Pick the smallest set that meets your application's needs — for most use cases, one or two.

The transaction trigger is emitted for transactions included in blocks. It does not expose transactions that remain pending or are dropped before inclusion, so it cannot be used to analyze the node's pending pool. Use the pending-pool APIs when you need the current local-node pending state.

Trigger payloads

The following lists the main fields in each trigger payload:

Block trigger (block)

timeStamp                     block timestamp
triggerName                   "blockTrigger"
blockNumber                   block height
blockHash                     block ID
transactionSize               number of transactions in the block
latestSolidifiedBlockNumber   most recent solidified height
transactionList               list of transaction hashes

Solidity trigger (solidity)

timeStamp                     timestamp of the block that triggered this notification
triggerName                   "solidityTrigger"
latestSolidifiedBlockNumber   most recent solidified height

Transaction trigger

blockHash                     block ID
blockNumber                   block height
energyUsage                   Energy deducted from the caller's staked or delegated resources
energyFee                     TRX burned to cover Energy, in sun
originEnergyUsage             Energy paid by the contract deployer
energyUsageTotal              total Energy (caller + deployer + burn)

Contract event trigger / solidityevent

transactionId                 transaction hash
contractAddress               contract address
originAddress                 transaction originator address
callerAddress                 currently an empty string
blockNumber                   containing block height
timeStamp                     block timestamp
eventSignature                Solidity event signature
topicMap                      map of indexed topics (name → value)
dataMap                       map of decoded non-indexed parameters
removed                       true if log was removed (reorg)

Contract log trigger / soliditylog

transactionId                 transaction hash
contractAddress               contract address
originAddress                 transaction originator address
callerAddress                 currently an empty string
blockNumber                   containing block height
timeStamp                     block timestamp
topicList                     list of raw 32-byte topics
data                          raw event data
removed                       true if log was removed (reorg)

For the canonical specification, see TIP-12 — Event subscription.

Filter syntax

The filter block narrows contract-event and contract-log streams. It does not apply to block / transaction triggers.

FieldMeaning
fromblock"", "earliest", or a specific height; lower bound (inclusive)
toblock"", "latest", or a specific height; upper bound (inclusive)
contractAddressList of contract addresses; empty list matches all
contractTopicList of event topic hashes; empty list matches all

Self-hosted plugin architecture

For Kafka or MongoDB, the Fullnode loads the corresponding plugin package at start-up. The official plugins are distributed as ZIP packages containing the plugin classes and runtime dependencies, and send events to Kafka or MongoDB.

┌────────────────┐      events       ┌──────────────┐      transport      ┌──────────────┐
│  TRON Fullnode │  ───────────────▶ │   Plugin     │  ────────────────▶  │  Consumer    │
│  (java-tron)   │   (in-process)    │  (ZIP)       │   (Kafka/Mongo)    │  (your app)  │
└────────────────┘                   └──────────────┘                     └──────────────┘

Two plugin implementations ship as reference:

PluginTransportBest forDoc
KafkaApache Kafka topicsDurable streams, multiple consumers, replay by offsetKafka plugin
MongoDBMongoDB collectionsEvent storage and filtered queries; pairs with TRON Event Query for HTTP queriesMongoDB plugin

The Fullnode's built-in ZeroMQ publisher serves the same role for cases where you don't want to operate a separate plugin or storage layer — see ZeroMQ event plugin.

You can write your own plugin against the java-tron event SPI — the entry point is the org.tron.common.logsfilter.IPluginEventListener interface. Kafka and MongoDB are reference implementations; the event-plugin source is the template.

Enabling event subscription

The following steps apply to the Kafka and MongoDB external plugins:

  1. Build or download the plugin ZIP package.
  2. Place the complete ZIP package somewhere readable by the Fullnode; do not extract it.
  3. Add the event.subscribe block to config.conf — set path to the ZIP package's absolute path, server to the transport endpoint, and topics / filter to your subscription.
  4. Set event.subscribe.enable = true in config.conf, then restart the Fullnode.

Per-plugin specifics (Kafka topic creation, MongoDB account provisioning, etc.) live in the per-plugin docs.

📘

Resource cost.

Event subscription adds CPU and memory load to the Fullnode. For high-throughput SR nodes, consider running event subscription on a separate dedicated Fullnode that syncs the same chain, so event processing does not compete with the consensus thread.


Related resources