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
| Method | Best for | Operates locally? | Historical backfill |
|---|---|---|---|
| TronGrid (hosted HTTPS query) | Front-ends, lightweight integrations | No — managed service | Yes (queryable by tx / block) |
| TronWeb (JavaScript SDK) | Browser and Node.js apps | No — wraps TronGrid | Yes (Mainnet + testnets; private chains not supported) |
| Built-in ZeroMQ (Fullnode publisher) | Dev work, a single in-network consumer | Yes — needs a Fullnode | Yes — 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 streams | Yes — needs a Fullnode + plugin + storage | Yes — 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.
| Version | Real-time pushes | Historical backfill | Default |
|---|---|---|---|
| V1.0 | Yes — events fire as new blocks are processed | No — only events produced from the moment the node starts | Yes (when event.subscribe.version is unset) |
| V2.0 | Yes | Yes — events from a configured starting height are replayed before the live stream | Opt-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.
-
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 -
Enable V2.0 in
config.conf:event.subscribe.version = 1 -
Retain your subscription configuration. Switching framework versions does not require changes to
topicsorfilter. For ZeroMQ, retain thenativeconfiguration. For external plugins, retain connection settings such asserveranddbconfig, and updatepathto point to the new package after upgrading. -
(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.
-
Set
event.subscribe.enable = trueinconfig.conf, then restart the Fullnode. Historical events replay first, then the live stream takes over.
VerifystartSyncBlockNumbefore 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[].triggerName | Event message contents | Typical use |
|---|---|---|
block | Newly produced block headers | Block-height monitors, head trackers |
transaction | Transactions included in blocks processed by the node | Transaction and resource-cost indexers |
contractevent | Decoded contract events (parsed against ABI) | Application back-ends consuming events as structured records |
contractlog | Raw contract logs (topics + data) | DeFi indexers, NFT trackers handling raw logs |
solidity | Most recent solidified block height | Exchanges, bridges — anything needing finality before acting |
solidityevent | Decoded contract events on solidified blocks | Same as contractevent but post-finality |
soliditylog | Raw contract logs on solidified blocks | Same 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 costSubscribing 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 hashesSolidity trigger (solidity)
timeStamp timestamp of the block that triggered this notification
triggerName "solidityTrigger"
latestSolidifiedBlockNumber most recent solidified heightTransaction 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.
| Field | Meaning |
|---|---|
fromblock | "", "earliest", or a specific height; lower bound (inclusive) |
toblock | "", "latest", or a specific height; upper bound (inclusive) |
contractAddress | List of contract addresses; empty list matches all |
contractTopic | List 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:
| Plugin | Transport | Best for | Doc |
|---|---|---|---|
| Kafka | Apache Kafka topics | Durable streams, multiple consumers, replay by offset | Kafka plugin |
| MongoDB | MongoDB collections | Event storage and filtered queries; pairs with TRON Event Query for HTTP queries | MongoDB 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:
- Build or download the plugin ZIP package.
- Place the complete ZIP package somewhere readable by the Fullnode; do not extract it.
- Add the
event.subscribeblock toconfig.conf— setpathto the ZIP package's absolute path,serverto the transport endpoint, andtopics/filterto your subscription. - Set
event.subscribe.enable = trueinconfig.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
- TronGrid V1 API overview — query on-chain events through hosted HTTPS APIs
- TronWeb event API — JavaScript SDK helpers
- ZeroMQ event plugin — Built-in pub-sub
- Kafka event plugin — Durable streams with replay
- MongoDB event plugin — Indexed event storage
- Event service framework V2.0 introduction — Background on V2.0
- TIP-12 — Event subscription — Canonical specification
- event-plugin source — Reference implementations and SPI template
- Listen to contract events — Application-level recipe
Updated 1 day ago