Events are an import functionality to help developers confirm, check, and search for the specific status of the smart contract.
# Event Decoding
This section explains how to decode events and obtain the result from the transactionHistory database.
Solidity Event Example:
## Event Structure
Solidity uses LOG instruction to record event information in a transaction. The structure in protobuf is as follows:
Decoding Events Example
The smart contract ABI for the solidity smart contract above is:
The corresponding event ABI is:
gettransactioninfobyid` to get the transaction result:
Check along with ABI:
topics is 69ca02dd4edd7bf0a4abb9ed3b7af3f14778db5d61921c7dc7cd545266326de2. It is the result of keccak("event(address,uint256)").
topics is 000000000000000000000000E552F6487585C2B58BC2C9BB4492BC1F17132CD0. It is the first indexed param (toAddress) with type address.
data is 0000000000000000000000000000000000000000000000000000000000000001. It is the param without being indexed (amount) with type uint256.
# Event Subscription Support
The Event Subscription supports event plug-ins, Kafka, and MongoDB plug-ins. Developers can customize their own plug-ins according to their own needs. It also supports subscription of chain data, such as block, transaction, contract log, contract event and so on. For transaction events, developers can retrieve information such as internal transactions, contract information, and so on. For contract events, developers could configure the contract addresses list or contract topic list to receive the specified events, and event subscription has low latency. The deployed Full Node receives event information immediately after the contract execution.
## Event Subscription Description
Event types that support subscriptions:
transactionTrigger: Transaction Event
blockTrigger: Block Event, triggered when the block is submitted.
contractLogTrigger: Smart Contract Log
contractEventTrigger: Smart Contract Event
The transaction information is represented by TransactionLogTrigger and includes the following parameters:
transactionId: transaction hash
The smart contract log object is represented by ContractLogTrigger and includes the following parameters:
removed: True if the log has been deleted, false if the log is deleted
## Event Plugin
<a href="https://github.com/tronprotocol/Documentation/blob/master/English_Documentation/TRON_Event_Subscribe/eventplugin_deploy.md" target="_blank">Kafka Plugin</a>
<a href="https://github.com/tronprotocol/Documentation/blob/master/English_Documentation/TRON_Event_Subscribe/mongodb_deploy.md" target="_blank">mongodb Plugin</a>
<a href="https://github.com/tronprotocol/Documentation/blob/master/English_Documentation/TRON_Event_Subscribe/tron-eventquery_deploy.md" target="_blank">Deploy</a>
<a href="https://github.com/tronprotocol/Documentation/blob/master/English_Documentation/TRON_Event_Subscribe/tron-eventquery.md" target="_blank">Tron Event Query Service</a>