0

Does anyone have an example of using PollingSubscribeProvider for subscription in a web app? I've attempted to use it, but I haven't been successful in making it work. Here's the documentation I've been referencing: https://tezostaquito.io/docs/next/subscribe_event/

I used this code

import { TezosToolkit, PollingSubscribeProvider } from '@taquito/taquito'

const Tezos = new TezosToolkit('https://ghostnet.ecadinfra.com')

Tezos.setStreamProvider(
  Tezos.getFactory(PollingSubscribeProvider)({
    shouldObservableSubscriptionRetry: true,
    pollingIntervalMilliseconds: 1500,
  })
)

try {
  const sub = Tezos.stream.subscribeEvent()

  sub.on('data', console.log)
} catch (e) {
  console.log(e)
}

and I get nothing when running that function on nodejs. I mean I get no errors but, I expected to get console.logs from all events. I also tried using the mainnet rpc and nothing happens.

1 Answer 1

0

It seems like you're trying to subscribe to an event, but you're not passing any conditions. You need to pass either the tag of the event or the contract address.

You can see a bit more detail here https://tezostaquito.io/docs/subscribe_event#usage

And even after you do so, the poll won't show anything until an activity on the blockchain involves something with that address, or an event with that specific tag

2
  • It said in the doc that I can call it without any params if I want to get all the events, that's why I called like that but good to know
    – user9011
    Jun 12, 2023 at 17:08
  • I think it should still do so, I think the reason you're not seeing anything is because perhaps no EMIT instructions (i.e. no events) were being called
    – user9011
    Jun 12, 2023 at 17:08

Your Answer

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