Adding the streams listeners programatically seems not working proper

We are registering/adding the contract/events to the streams API using this method Moralis.Streams.addAddress(). Usually, when we add the streams, if there is no change in stream properties it won’t create an additional stream but unfortunately, our streams are getting duplicated somehow even though the data is the same on both.

We have 15+ streams for our production server and there are a few duplicated streams are being created whenever our server is restarted which triggers the stream registration code

maybe is some code that creates a new stream config, how do you get the stream id to use for

For the duplicated stream, the stream ids are unique

you have duplicated stream configs with the same stream ids?

No, the id is different

Ok, how did they get created in the first place? It has to be a code that creates them. You can hardcode the stream id in your code to make sure that you don’t create a new stream id


const stream = {
  chains: [EvmChain.ETHEREUM, EvmChain.POLYGON], // list of blockchains to monitor
  description: "monitor Bobs wallet", // your description
  tag: "bob", // give it a tag
  webhookUrl: "https://YOUR_WEBHOOK_URL", // webhook url to receive events,
  includeNativeTxs: true,
};

const newStream = await Moralis.Streams.add(stream);
const { id } = newStream.toJSON();

streamId is being received from here right ? If the streamConfig is same, the id should be same (This is the expected behaviour)

This code will create a new stream every time is run. You have to list current streams to identify your previously created stream or to hardcode directly the stream id