Webhook not creating and updating when webhook call then create auto new stream id but this not happend with this code

const Moralis = require(“moralis”);
Moralis.default.start({
apiKey: process.env.MORALIS_KEY,
});
const stream = async () => {
let options = {
chains: [
0x1, 0x5, 0xaa36a7, 0x38, 0x89, 0xfa, 0xa86a, 0x19, 0x7e4, 0xa4b1,
0x2105,
],
description: “Listen to Transfer”,
tag: “transfers”,
includeContractLogs: false,
includeNativeTxs: true,
webhookUrl: “” ,
};
}
let userAdresses = “0xb887F4575BcF268e16ccf00C1Fe68D30730ab676”;
const newStream = await Moralis.default.Streams.add(options);

const { id } = newStream.toJSON();

let data = await Moralis.default.Streams.addAddress({
address: userAdresses,
id,
});
};

1 Like

Hi, it seems like the code is not structured properly and the stream() function is never called. I refactored in the example below, you can test it with your own key and webhook

const Moralis = require("moralis");

Moralis.default.start({
    apiKey: "your_key",
});
const stream = async () => {
    let options = {
        chains: [
            0x1, 0x5, 0xaa36a7, 0x38, 0x89, 0xfa, 0xa86a, 0x19, 0x7e4, 0xa4b1,
            0x2105,
        ],
        description: "Listen to Transfer",
        tag: "transfers",
        includeContractLogs: false,
        includeNativeTxs: true,
        webhookUrl: "https://webhook.site/00dd7e48-789d-4aa9-8f41-4064d0f6476e",
    };
    let userAdresses = "0xb887F4575BcF268e16ccf00C1Fe68D30730ab676";
    const newStream = await Moralis.default.Streams.add(options);

    const { id } = newStream.toJSON();

    let data = await Moralis.default.Streams.addAddress({
        address: userAdresses,
        id,
    });

    console.log("address added to stream", {
        streamId: data.raw.streamId,
        address: data.raw.address,
    });
};

stream();

Hey lulian,
I am using same the same code as you mention but stream not create.

Did you receive any error messages for the code?