Reputation: 101
MultiversX has events that can be emitted during smart contract execution: https://docs.multiversx.com/developers/developer-reference/sc-annotations/#events
How would I query for or subscribe to these events? On Ethereum, it would be possible to monitor/query such events as they execute using web3 or the Ethereum client node RPC. Is there something similar on MultiversX?
Upvotes: 3
Views: 830
Reputation: 743
You have a few ways to use those events.
You can use the api to fetch transactions for an account and then use the transaction endpoint to get more details for those transactions and read the events.
The endpoint would be:
http://testnet-gateway.elrond.com/transaction/<txhash>?withResults=true
(Note: Event data and smart contract results will only be returned if you add the ?withResults=true
query param)
You can also use the transaction processor package to process all transactions that are notarized on the blockchain and again get the event data using the transaction endpoint.
Those events are also indexed in the elastic search instance so you can use elastic search to query for information. Either by setting up your own observer-squad with elastic search or by using the public indexer. (https://testnet-index.elrond.com/logs/_search)
Upvotes: 2