Event Subscription

In version 3.5, the Pollux development team introduced an event subscription mechanism, enabling developers to receive events triggered on the chain by the event plugin.

Services

Pollux provides the following ways to get events.

  1. Pollux provides the following ways to get events.

  2. PolluxGrid encapsulates the event plugin interface and provides a public, friendly https event query interface.

  3. PolluxWeb provides the encapsulated js methods to get events.

  4. Set up an event plugin locally to provide event queries.

  5. The Pollux development team released two event plug-ins, kafka & mongodb plug-ins.

  6. Supporting subscription of chain data, such as block, transaction, contract log, contract event and so on, developers can also customize their own plug-ins according to their own needs.

  7. Event query service pollux-eventquery, online Event query service provided.

  8. Use Java-pollux's built-In message queue for event subscription.

Plugin

The function of the Poxchain plugin is to implement event dump. Developers can customize it according to their needs, such as Message queue, Kafka, MongoDB, or writing to local files.

To use the event plugin, set useNativeQueue to false in the node configuration file, as follows:

event.subscribe = {
    PRC = {
      usePoxchainQueue = false // if true, use Pollux message queue, else use event plugin.
      bindport = 5555 // bind port
      sendqueuelength = 1000 // max length of send queue
    }
   ...
}

The plugins offered by the Pollux development team are independent of java-Pollux and are not loaded by default. They can be enabled by configuring command line parameters. By default, only subscriptions to smart contract events are supported. Developers can subscribe to other triggers by modifying configuration files, and they have flexibility in defining plug-in configuration files, including message queue server addresses, defined Trigger types, and so on.

Event Type

POX Event Subscription supports 4 types of event:

1.Transaction Event

The parameters passed to Subscriber:

polluxId: pollux hash
blockHash: block hash
blockNumber: block number
powerConsumption: power consumption
powerFee: power fee
sourcePowerConsumption: source power consumption  
powerConsumptionTotal: total power consumption total

2.Block Event

The parameters passed to Subscriber:

blockHash: PRC hash
blockNumber: PRC number
transactionSize: the number of transactions in a PRC
latestSolidifiedBlockNumber: the latest solidified PRC number
transactionList: the transactions HASH list

3.Contract Event

The parameters passed to Subscriber:

transactionId: identification of the transaction
contractAddress: address of the contract
callerAddress: address of the contract caller
blockNumber: the number of the block where contract-related events are recorded
blockTimestamp: timestamp of the block
eventSignature: signature of the event
topicMap: map of topics in Solidity language
data: information in Solidity language
removed: 'true' indicates that the log has been removed

4.Contract Log Event

The parameters passed to Subscriber:

transactionId: hash of the transaction
contractAddress: address of the contract
callerAddress: address of the caller in the contract
blockNumber: the block number where the contract-related events are recorded
blockTimestamp: the timestamp of the block
contractTopics: the list of topics in the Solidity language
data: the information in Solidity language
removed: 'true' indicates that the log has been removed

Contract Event and Contract Log Even support event filter function which includes:

fromBlock: the commencement block number
toBlock: the conclusion block number
contractAddress: list of Pollux addresses
contractTopics: list of PRC topics

Last updated