4

Suppose I have a dapp that monitors transaction of some assets. The smart contract would be generating transactions and I'd get messages like

"executed transaction: 7f0cb79e317e874ba74530e03dab2cdae66497925ce05637e32ae0893529886e

104 bytes 279 us"

For the UI, which is probably running with eosjs.

How can I know when these transactions happen?

Is it possible to monitor certain kinds of events from the blockchain? E.g if I have a pokemon-esque game and someone posts a challenge using a smart contract action

1
  • When you push a transaction, eosjs api returns a json object which has the transaction_id. Do check that. HTH Commented Aug 3, 2018 at 6:40

2 Answers 2

2

If I understand your question correctly, it seems like impossible to monitor transactions (in terms of receiving notifications about new blocks and transactions from the blockchain) with eosjs (at least for the current moment).

As taokayan (contributor) pointed out:

There's no direct way to do it [notify 3rd party service] within the current version [of eosio software]. However, you can make a plugin to capture all the blocks & transactions then notify 3rd party service. Or, alternatively, call "get table" from time to time.

Also, chris-allnutt (contributor) said that:

Eosjs doesn't have anything internal to poll nodes and would more than likely be out of scope for its intended usage - here is a link

IMHO, the state of the art solution is the following. If you have a running nodeos instance and it is synchronized with the mainnet you can try using mongo_db_plugin to store all the blocks and then query mongodb to extract transactions you need. The drawback is that you still won't be able to get notifications from the mongo until setting up a replica set of several mongod instances (which consumes a lot of memory).

0

Check out the demux library for listening to EOS blockchain events. As far as I know there is no event logs like in Ethereum so you have to poll the api node

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.