Hi, I have a question about streams

in this page
https://forum.moralis.io/t/using-event-syncs-in-moralis-sdk-v2-parse-server/20202
I can see an example of saving the data in the moralis or parse-server db, but the response from the stream is this:

{
    "confirmed": true,
    "chainId": "0x13881",
    "abi": [
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": true,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint8",
                    "name": "auctionType",
                    "type": "uint8"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "auctionEndTime",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "minPrice",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "increment",
                    "type": "uint256"
                },
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "seller",
                    "type": "address"
                }
            ],
            "name": "AuctionCreated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": true,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "highestBidder",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "highestBid",
                    "type": "uint256"
                }
            ],
            "name": "AuctionEnded",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint64",
                    "name": "auctionEndPeriod",
                    "type": "uint64"
                }
            ],
            "name": "AuctionPeriodUpdated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "auctionSettler",
                    "type": "address"
                }
            ],
            "name": "AuctionSettled",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftOwner",
                    "type": "address"
                }
            ],
            "name": "AuctionWithdrawn",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "bidder",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "ethAmount",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "erc20Token",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenAmount",
                    "type": "uint256"
                }
            ],
            "name": "BidMade",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": true,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "bidder",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "bidAmount",
                    "type": "uint256"
                }
            ],
            "name": "BidPlaced",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "highestBidder",
                    "type": "address"
                }
            ],
            "name": "BidWithdrawn",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint128",
                    "name": "newBuyNowPrice",
                    "type": "uint128"
                }
            ],
            "name": "BuyNowPriceUpdated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                }
            ],
            "name": "HighestBidTaken",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "newMinPrice",
                    "type": "uint256"
                }
            ],
            "name": "MinimumPriceUpdated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftSeller",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint128",
                    "name": "nftHighestBid",
                    "type": "uint128"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftHighestBidder",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftRecipient",
                    "type": "address"
                }
            ],
            "name": "NFTTransferredAndSellerPaid",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftSeller",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "erc20Token",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint128",
                    "name": "minPrice",
                    "type": "uint128"
                },
                {
                    "indexed": false,
                    "internalType": "uint128",
                    "name": "buyNowPrice",
                    "type": "uint128"
                },
                {
                    "indexed": false,
                    "internalType": "uint32",
                    "name": "auctionBidPeriod",
                    "type": "uint32"
                },
                {
                    "indexed": false,
                    "internalType": "uint32",
                    "name": "bidIncreasePercentage",
                    "type": "uint32"
                },
                {
                    "indexed": false,
                    "internalType": "address[]",
                    "name": "feeRecipients",
                    "type": "address[]"
                },
                {
                    "indexed": false,
                    "internalType": "uint32[]",
                    "name": "feePercentages",
                    "type": "uint32[]"
                }
            ],
            "name": "NftAuctionCreated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftSeller",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "erc20Token",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint128",
                    "name": "buyNowPrice",
                    "type": "uint128"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "whitelistedBuyer",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "address[]",
                    "name": "feeRecipients",
                    "type": "address[]"
                },
                {
                    "indexed": false,
                    "internalType": "uint32[]",
                    "name": "feePercentages",
                    "type": "uint32[]"
                }
            ],
            "name": "SaleCreated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "from",
                    "type": "address"
                },
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "to",
                    "type": "address"
                },
                {
                    "indexed": true,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                }
            ],
            "name": "Transfer",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "nftContractAddress",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "tokenId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "newWhitelistedBuyer",
                    "type": "address"
                }
            ],
            "name": "WhitelistedBuyerUpdated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": true,
                    "internalType": "address",
                    "name": "recipient",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "amount",
                    "type": "uint256"
                }
            ],
            "name": "Withdrawal",
            "type": "event"
        }
    ],
    "streamId": "b78a3913-5432-4264-8097-7f0b579c511a",
    "tag": "marketKoolinart",
    "retries": 0,
    "block": {
        "number": "35110649",
        "hash": "0xc6fa2655f2320c2fffd7b05844947f0cadfdb0b9e39395038f4272d092574223",
        "timestamp": "1683064970"
    },
    "logs": [
        {
            "logIndex": "0",
            "transactionHash": "0xce7ea797361e3536071da628c4790b85373829cf9561f4fa29170f2310aa83e8",
            "address": "0xe76bc6e52c2db6054c4e63f2c9e72ade240ac3de",
            "data": "0x0000000000000000000000001db221bc1505f77d14b365897e0b1b4508baa8a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a136632e5123be81d620ecbdf5669741e32e3d7500000000000000000000000011142365ddbc92c3547b8a074289409b5432ca8b0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b0a7c00ea503adbdfe0071bdd9eb6fbb18e7c6b500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000005",
            "topic0": "0xb4cb1faa7b4f2b837334e4a12fb94a1cfc320c32b70dd31e113d1795b9d0f056",
            "topic1": null,
            "topic2": null,
            "topic3": null
        },
        {
            "logIndex": "1",
            "transactionHash": "0xce7ea797361e3536071da628c4790b85373829cf9561f4fa29170f2310aa83e8",
            "address": "0x0000000000000000000000000000000000001010",
            "data": "0x000000000000000000000000000000000000000000000000000106a9b9040a0000000000000000000000000000000000000000000000000050093633198f8d540000000000000000000000000000000000000000000007c93b593fe07390a18500000000000000000000000000000000000000000000000050082f89608b83540000000000000000000000000000000000000000000007c93b5a468a2c94ab85",
            "topic0": "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63",
            "topic1": "0x0000000000000000000000000000000000000000000000000000000000001010",
            "topic2": "0x000000000000000000000000a136632e5123be81d620ecbdf5669741e32e3d75",
            "topic3": "0x0000000000000000000000003a22c8bc68e98b0faf40f349dd2b2890fae01484"
        }
    ],
    "txs": [
        {
            "hash": "0xce7ea797361e3536071da628c4790b85373829cf9561f4fa29170f2310aa83e8",
            "gas": "192534",
            "gasPrice": "1500000016",
            "nonce": "24",
            "input": "0xf45671f10000000000000000000000001db221bc1505f77d14b365897e0b1b4508baa8a3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011142365ddbc92c3547b8a074289409b5432ca8b0000000000000000000000000000000000000000000000001bc16d674ec80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b0a7c00ea503adbdfe0071bdd9eb6fbb18e7c6b500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000005",
            "transactionIndex": "0",
            "fromAddress": "0xa136632e5123be81d620ecbdf5669741e32e3d75",
            "toAddress": "0xe76bc6e52c2db6054c4e63f2c9e72ade240ac3de",
            "value": "0",
            "type": "2",
            "v": "1",
            "r": "112454914985421993243539775100918453554364874579899827459310319436727367478546",
            "s": "31579467393975761118355844565324807752794005760628610573678864325917930359714",
            "receiptCumulativeGasUsed": "192534",
            "receiptGasUsed": "192534",
            "receiptContractAddress": null,
            "receiptRoot": null,
            "receiptStatus": "1"
        }
    ],
    "txsInternal": [],
    "erc20Transfers": [],
    "erc20Approvals": [],
    "nftTokenApprovals": [],
    "nftApprovals": {
        "ERC721": [],
        "ERC1155": []
    },
    "nftTransfers": [],
    "nativeBalances": []
}

and the stream configuration is this:

,

The question is: before, just by putting the abi and selecting the event that would be saved, it would be done automatically, should I create something like the example link? so that the data is stored as it would capture only the events because if the stream returns information to me, I do not see that it returns what I am requesting from the abi example AuctionCreated(address,uint256,uint8,uint256,uint256,uint256,address) This should return because it is running on the smart contract and it doesn’t, do I have something wrong in the configuration?

What I am trying to say is that with the configuration set, which I mentioned before, it does not return the data I need in the stream response. What I need is to read the events of the smartcontract as it was, could you tell me how I can configure the stream as before, please.

the event info is here, it has to be parsed with the abi to get the values for the event parameters

there is code in the self hosted parse server that does that processing, there should also be code in the javascript sdk that can process an event, you can also use ethers directly to do that interpretation starting with the abi and the logs info

topic0 in particular will correspond to a particular event signature

but it’s a bad answer, before I got minimum price, fixed price, tokenId From, to , and other details? So the question is am I configuring something wrong? Because before with the moralis server, the data that was saved automatically did it, so if I do the same thing and the response is not the same, how can I make it so that when the contract function is executed, the event is the one that responds to the stream. if I make myself understand?

old server:

then the method to apply would be this https://github.com/MoralisWeb3/streams-beta#parsing-smart-contract-events?
Thank you very much for the help, and always respond. I got the link in the forum, if that’s the case, I’ll apply it and comment if everything went well. Thank you.

what you see in that link is the idea of what you have to do, you receive the row data from streams api and after that you can use that code or other equivalent code that interprets that row data to get the data that you are expecting

1 Like

Hello, could you please help me with this typescript error: The property 'id' does not exist in the type 'CreateStreamEvmResponseAdapter'.ts(2339)
? This would be a solution: const { id }: any = stream;
and for prettier /* eslint-disable @typescript-eslint/no-explicit-any */
Am I correct or is there another way?

  const { id } = stream;


  await Moralis.Streams.addAddress({
    id,
    address: "0xe76bc6e52c2db6054c4e63f2c9e72ade240ac3de", 
  });

I don’t understand these two values { webhook, tag } where I get them from, const decodedLogs = Moralis.Streams.parsedLogs<MyEvent>({ webhook, tag }); the webhook is: config.STREAMS_WEBHOOK_URL ?

complete code:

app.get("/AuctionCreated", async (req, res) => {

   const { body } = req;
   console.log("body", body);

   const stream = await Moralis.Streams.add({
     chains: [EvmChain.MUMBAI],
     description: 'AuctionCreatedERC721',
     tag: 'AuctionsCreated',
     abi: marketAbi,
     includeContractLogs: true,
     webhookUrl: config.STREAMS_WEBHOOK_URL,
     topic0: ['AuctionCreated(address,uint256,uint8,uint256,uint256,uint256,address)']
   });

   const { id }: any = stream;


   await Moralis.Streams.addAddress({
     go,
     address: "0xe76bc6e52c2db6054c4e63f2c9e72ade240ac3de",
   });

   interface MyEvent {
     from: string;
     to: string;
   }
  
   const decodedLogs = Moralis.Streams.parsedLogs<MyEvent>({ webhook, tag });
  
   decodedLogs[0];

   return res.status(200).json(stream);
  
} )

note: I know that the interface is not that.

Hi @davidzuccarini

Can you try with the latest SDK version?

I don’t see any typescript error in the latest sdk when using id params in addAddress function.

hi john,yes i have "moralis": "^2.19.0",
from what I notice the id error comes from here the typed one

const stream = await Moralis.Streams.add({
     chains: [EvmChain.MUMBAI],
     description: 'AuctionCreatedERC721',
     tag: 'AuctionsCreated',
     abi: marketAbi,
     includeContractLogs: true,
     webhookUrl: config.STREAMS_WEBHOOK_URL,
     topic0: ['AuctionCreated(address,uint256,uint8,uint256,uint256,uint256,address)']
   });

   const { id }: any = stream;

Replace it with this. It also exports the type so no need to add any.

const { id } = stream.result;

Thanks a lot John it worked :raised_hands:, and referring to these values { webhook, tag } here const decodedLogs = Moralis.Streams.parsedLogs<MyEvent>({ webhook, tag });

what values do you get? should i get them? In the case of webhook, do I pass config.STREAMS_WEBHOOK_URL?

You can pass the entire json data which you received in webhook body, as the tag value is also included on the received data.

ok, I understand, that would be in the case of the tag that I extract it in this way: const { id, tag } = stream.result;
and for the webhook value?

Hello, I have a question about the stream, sorry for the lack of knowledge, if I create a stream through the moralis interface or by creating a new url

app.get("/streams-webhook", async (req, res) => {


   const stream = await Moralis.Streams.add({
     webhookUrl: `${url}${config.STREAMS_WEBHOOK_URL}`,
     chains: [EvmChain.MUMBAI],
     description: 'AuctionsCreated721',
     tag: 'AuctionsCreated',
     includeContractLogs: true,
     abi: marketAbi,
     topic0: [
       'AuctionCreated(address,uint256,uint8,uint256,uint256,uint256,address)',
       'NftAuctionCreated(address,uint256,address,address,uint128,uint128,uint32,uint32,address[],uint32[])'
     ]
   })

   const { id } = stream.toJSON();

   await Moralis.Streams.addAddress({
     go,
     address: [marketAddress],
   });


   const { headers, body, tag }: any = req;
   console.log("body", body)

   if (body.confirmed) {
     return res.status(200).json();
   }


   let newTransfers = [];

   for (Transfer of body.erc20Transfers){
      newTransfers.push({
       fromAddress: Transfer.from,
       toAddress: Transfer.to,
       value: Transfer.value,
       valueWithDecimals: Transfer.valueWithDecimals,
      })
   }

   if(newTransfers.length > 0 ){
     await Transfer.insertMany(newTransfers)
     console.log("added New Transfers To DB")
   }

   res.send('ok');
  

   return res.status(400).json({ error: "No body provided" });
  
})

where does the data come from?

to this url?


app.post('/webhook',async ( req , res) => {
  
   const webhook: Types.IWebhook = req.body;

   return res.status(200).json()
})

?

After this, should I verify the data? and after this I must decode the data? and after that save them in the db right? If there is something that is not like that, can you please let me know? If not, how do I get the data and decode it? I’m a little confused because I see different methods in several places but I don’t see an example with respect to the whole thing together, I don’t know if I make myself understand.

You can pass the entire webhook data received in stream body.

const webhook = req.body;

const decodedLogs = Moralis.Streams.parsedLogs<MyEvent>(webhook);

The value of the url is the url of your hosted server. If you deploy it this server you will have to update the server url accordingly.

Here is an example code that shows how you can verify the streams based on the sender. I hope this helps.

You can save the data once verified

Yes, I have tried this, but the back end, Not Moralis, returns this error.

app.get("/streams-webhook", async (req, res) => {

  const stream = await Moralis.Streams.add({
    webhookUrl: `${url}${config.STREAMS_WEBHOOK_URL}`,
    chains: [EvmChain.MUMBAI],
    description: 'AuctionsCreated721',
    tag: 'AuctionsCreated',
    includeContractLogs: true,
    abi: marketAbi,
    topic0: [
      'AuctionCreated(address,uint256,uint8,uint256,uint256,uint256,address)', 
      'NftAuctionCreated(address,uint256,address,address,uint128,uint128,uint32,uint32,address[],uint32[])'
    ]
  });
  
  console.log('aqui1', );

  const { headers, body, tag  }: any = req;
  console.log('aqui2', );

  const webhook: Types.IWebhook = req.body;
  console.log('aqui3', );

  try {
    console.log('aqui4', );

    Moralis.Streams.verifySignature({
      body,
      signature: headers["x-signature"],
    });
    console.log('aqui5', );


  console.log('aqui6', );


  const { id } = stream.toJSON();
  console.log('aqui7', );

  await Moralis.Streams.addAddress({
    id,
    address: [marketAddress],
  });
  console.log('aqui8', );

  console.log("webhook", webhook)
  console.log("body", body)

  if (body.confirmed) {
    return res.status(200).json();
  }


  let newTranfers = []; 

  for (Transfer of body.erc20Transfers){
     newTranfers.push({
      fromAddress: Transfer.from,
      toAddress: Transfer.to,
      value: Transfer.value,
      valueWithDecimals: Transfer.valueWithDecimals,
     })
  }

  if(newTranfers.length > 0 ){
    await Transfer.insertMany(newTranfers)
    console.log("added New Transfers To DB")
  }

  res.send('ok');
  

  return res.status(400).json({ error: "No body provided" });
} catch (e) {
  console.log("Not Moralis");
  return res.status(400).json();
}
})

If I put the code like this:

and I enter the url /streams-webhook, the app stops: log back-end:

..... more data
          _requestCert: true,
          _rejectUnauthorized: true,
          parser: null,
          _httpMessage: [Circular *2],
          timeout: 20000,
          [Symbol(res)]: TLSWrap {
            _parent: [TCP],
            _parentWrap: undefined,
            _secureContext: [SecureContext],
            reading: true,
            onkeylog: [Function: onkeylog],
            onhandshakestart: {},
            onhandshakedone: [Function (anonymous)],
            onocspresponse: [Function: onocspresponse],
            onnewsession: [Function: onnewsessionclient],
            onerror: [Function: onerror],
            [Symbol(owner_symbol)]: [Circular *1]
          },
          [Symbol(verified)]: true,
          [Symbol(pendingSession)]: null,
          [Symbol(async_id_symbol)]: 3078,
          [Symbol(kHandle)]: TLSWrap {
            _parent: [TCP],
            _parentWrap: undefined,
            _secureContext: [SecureContext],
            reading: true,
            onkeylog: [Function: onkeylog],
            onhandshakestart: {},
            onhandshakedone: [Function (anonymous)],
            onocspresponse: [Function: onocspresponse],
            onnewsession: [Function: onnewsessionclient],
            onerror: [Function: onerror],
            [Symbol(owner_symbol)]: [Circular *1]
          },
          [Symbol(lastWriteQueueSize)]: 0,
          [Symbol(timeout)]: <ref *3> Timeout {
            _idleTimeout: 20000,
            _idlePrev: [TimersList],
            _idleNext: [TimersList],
            _idleStart: 17842,
            _onTimeout: [Function: bound ],
            _timerArgs: undefined,
            _repeat: null,
            _destroyed: false,
            [Symbol(refed)]: false,
            [Symbol(kHasPrimitive)]: false,
            [Symbol(asyncId)]: 3087,
            [Symbol(triggerId)]: 3081
          },
          [Symbol(kBuffer)]: null,
          [Symbol(kBufferCb)]: null,
          [Symbol(kBufferGen)]: null,
          [Symbol(kCapture)]: false,
          [Symbol(kSetNoDelay)]: false,
          [Symbol(kSetKeepAlive)]: true,
          [Symbol(kSetKeepAliveInitialDelay)]: 60,
          [Symbol(kBytesRead)]: 0,
          [Symbol(kBytesWritten)]: 0,
          [Symbol(connect-options)]: {
            rejectUnauthorized: true,
            ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
            checkServerIdentity: [Function: checkServerIdentity],
            minDHSize: 1024,
            maxRedirects: 21,
            maxBodyLength: Infinity,
            protocol: 'https:',
            path: null,
            method: 'PUT',
            headers: [Object: null prototype],
            agents: [Object],
            auth: undefined,
            beforeRedirect: [Function: dispatchBeforeRedirect],
            beforeRedirects: [Object],
            hostname: 'api.moralis-streams.com',
            port: 443,
            agent: undefined,
            nativeProtocols: [Object],
            pathname: '/streams/evm',
            _defaultAgent: [Agent],
            host: 'api.moralis-streams.com',
            servername: 'api.moralis-streams.com',
            _agentKey: 'api.moralis-streams.com:443:::::::::::::::::::::',
            encoding: null,
            singleUse: true
          },
          [Symbol(RequestTimeout)]: undefined
        },
        _header: 'PUT /streams/evm HTTP/1.1\r\n' +
          'Accept: application/json, text/plain, */*\r\n' +
          'Content-Type: application/json\r\n' +
          'x-moralis-platform: NodeJS SDK\r\n' +
          'x-moralis-platform-version: 2.19.0\r\n' +
          'x-moralis-build-target: node\r\n' +
          'x-api-key: all3RzGKuVBfOjmsNNW1w4NEmSALcqdKeYG4K6SXlGQZPp4nPpsenLEVdahKBrZQ\r\n' +
          'User-Agent: axios/1.3.6\r\n' +
          'Content-Length: 15338\r\n' +
          'Accept-Encoding: gzip, compress, deflate, br\r\n' +
          'Host: api.moralis-streams.com\r\n' +
          'Connection: close\r\n' +
          '\r\n',
        _keepAliveTimeout: 0,
        _onPendingData: [Function: nop],
        agent: Agent {
          _events: [Object: null prototype] {
            free: [Function (anonymous)],
            newListener: [Function: maybeEnableKeylog]
          },
          _eventsCount: 2,
          _maxListeners: undefined,
          defaultPort: 443,
          protocol: 'https:',
          options: [Object: null prototype] { path: null },
          requests: [Object: null prototype] {},
          sockets: [Object: null prototype] {
            'api.moralis-streams.com:443:::::::::::::::::::::': [Array]
          },
          freeSockets: [Object: null prototype] {},
          keepAliveMsecs: 1000,
          keepAlive: false,
          maxSockets: Infinity,
          maxFreeSockets: 256,
          scheduling: 'lifo',
          maxTotalSockets: Infinity,
          totalSocketCount: 1,
          maxCachedSessions: 100,
          _sessionCache: { map: [Object], list: [Array] },
          [Symbol(kCapture)]: false
        },
        socketPath: undefined,
        method: 'PUT',
        maxHeaderSize: undefined,
        insecureHTTPParser: undefined,
        path: '/streams/evm',
        _ended: true,
        res: IncomingMessage {
          _readableState: ReadableState {
            objectMode: false,
            highWaterMark: 16384,
            buffer: [BufferList],
            length: 0,
            pipes: [],
            flowing: true,
            ended: true,
            endEmitted: true,
            reading: false,
            constructed: true,
            sync: true,
            needReadable: false,
            emittedReadable: false,
            readableListening: false,
            resumeScheduled: false,
            errorEmitted: false,
            emitClose: true,
            autoDestroy: true,
            destroyed: true,
            errored: null,
            closed: true,
            closeEmitted: true,
            defaultEncoding: 'utf8',
            awaitDrainWriters: null,
            multiAwaitDrain: false,
            readingMore: true,
            dataEmitted: true,
            decoder: null,
            encoding: null,
            [Symbol(kPaused)]: false
          },
          _events: [Object: null prototype] {
            end: [Array],
            error: [Function: handleStreamError],
            data: [Function: handleStreamData],
            aborted: [Function: handlerStreamAborted]
          },
          _eventsCount: 4,
          _maxListeners: undefined,
          socket: <ref *1> TLSSocket {
            _tlsOptions: [Object],
            _secureEstablished: true,
            _securePending: false,
            _newSessionPending: false,
            _controlReleased: true,
            secureConnecting: false,
            _SNICallback: null,
            servername: 'api.moralis-streams.com',
            alpnProtocol: false,
            authorized: true,
            authorizationError: null,
            encrypted: true,
            _events: [Object: null prototype],
            _eventsCount: 10,
            connecting: false,
            _hadError: false,
            _parent: null,
            _host: 'api.moralis-streams.com',
            _readableState: [ReadableState],
            _maxListeners: undefined,
            _writableState: [WritableState],
            allowHalfOpen: false,
            _sockname: null,
            _pendingData: null,
            _pendingEncoding: '',
            server: undefined,
            _server: null,
            ssl: [TLSWrap],
            _requestCert: true,
            _rejectUnauthorized: true,
            parser: null,
            _httpMessage: [Circular *2],
            timeout: 20000,
            [Symbol(res)]: [TLSWrap],
            [Symbol(verified)]: true,
            [Symbol(pendingSession)]: null,
            [Symbol(async_id_symbol)]: 3078,
            [Symbol(kHandle)]: [TLSWrap],
            [Symbol(lastWriteQueueSize)]: 0,
            [Symbol(timeout)]: [Timeout],
            [Symbol(kBuffer)]: null,
            [Symbol(kBufferCb)]: null,
            [Symbol(kBufferGen)]: null,
            [Symbol(kCapture)]: false,
            [Symbol(kSetNoDelay)]: false,
            [Symbol(kSetKeepAlive)]: true,
            [Symbol(kSetKeepAliveInitialDelay)]: 60,
            [Symbol(kBytesRead)]: 0,
            [Symbol(kBytesWritten)]: 0,
            [Symbol(connect-options)]: [Object],
            [Symbol(RequestTimeout)]: undefined
          },
          httpVersionMajor: 1,
          httpVersionMinor: 1,
          httpVersion: '1.1',
          complete: true,
          rawHeaders: [
            'Date',
            'Sat, 06 May 2023 22:17:30 GMT',
            'Content-Type',
            'application/json; charset=utf-8',
            'Content-Length',
            '48',
            'Connection',
            'close',
            'X-Powered-By',
            'Express',
            'Access-Control-Allow-Origin',
            '*',
            'ETag',
            'W/"30-+HsFdZyXWyUrgHppl86GBEij3+4"',
            'X-Response-Time',
            '307.910ms',
            'Vary',
            'Accept-Encoding',
            'Strict-Transport-Security',
            'max-age=15724800; includeSubDomains',
            'CF-Cache-Status',
            'DYNAMIC',
            'Server',
            'cloudflare',
            'CF-RAY',
            '7c3497f66b0ec202-MDE'
          ],
          rawTrailers: [],
          aborted: false,
          upgrade: false,
          url: '',
          method: null,
          statusCode: 400,
          statusMessage: 'Bad Request',
          client: <ref *1> TLSSocket {
            _tlsOptions: [Object],
            _secureEstablished: true,
            _securePending: false,
            _newSessionPending: false,
            _controlReleased: true,
            secureConnecting: false,
            _SNICallback: null,
            servername: 'api.moralis-streams.com',
            alpnProtocol: false,
            authorized: true,
            authorizationError: null,
            encrypted: true,
            _events: [Object: null prototype],
            _eventsCount: 10,
            connecting: false,
            _hadError: false,
            _parent: null,
            _host: 'api.moralis-streams.com',
            _readableState: [ReadableState],
            _maxListeners: undefined,
            _writableState: [WritableState],
            allowHalfOpen: false,
            _sockname: null,
            _pendingData: null,
            _pendingEncoding: '',
            server: undefined,
            _server: null,
            ssl: [TLSWrap],
            _requestCert: true,
            _rejectUnauthorized: true,
            parser: null,
            _httpMessage: [Circular *2],
            timeout: 20000,
            [Symbol(res)]: [TLSWrap],
            [Symbol(verified)]: true,
            [Symbol(pendingSession)]: null,
            [Symbol(async_id_symbol)]: 3078,
            [Symbol(kHandle)]: [TLSWrap],
            [Symbol(lastWriteQueueSize)]: 0,
            [Symbol(timeout)]: [Timeout],
            [Symbol(kBuffer)]: null,
            [Symbol(kBufferCb)]: null,
            [Symbol(kBufferGen)]: null,
            [Symbol(kCapture)]: false,
            [Symbol(kSetNoDelay)]: false,
            [Symbol(kSetKeepAlive)]: true,
            [Symbol(kSetKeepAliveInitialDelay)]: 60,
            [Symbol(kBytesRead)]: 0,
            [Symbol(kBytesWritten)]: 0,
            [Symbol(connect-options)]: [Object],
            [Symbol(RequestTimeout)]: undefined
          },
          _consuming: false,
          _dumped: false,
          req: [Circular *2],
          responseUrl: 'https://api.moralis-streams.com/streams/evm',
          redirects: [],
          [Symbol(kCapture)]: false,
          [Symbol(kHeaders)]: {
            date: 'Sat, 06 May 2023 22:17:30 GMT',
            'content-type': 'application/json; charset=utf-8',
            'content-length': '48',
            connection: 'close',
            'x-powered-by': 'Express',
            'access-control-allow-origin': '*',
            etag: 'W/"30-+HsFdZyXWyUrgHppl86GBEij3+4"',
            'x-response-time': '307.910ms',
            vary: 'Accept-Encoding',
            'strict-transport-security': 'max-age=15724800; includeSubDomains',
            'cf-cache-status': 'DYNAMIC',
            server: 'cloudflare',
            'cf-ray': '7c3497f66b0ec202-MDE'
          },
          [Symbol(kHeadersCount)]: 26,
          [Symbol(kTrailers)]: null,
          [Symbol(kTrailersCount)]: 0,
          [Symbol(RequestTimeout)]: undefined
        },
        aborted: false,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        reusedSocket: false,
        host: 'api.moralis-streams.com',
        protocol: 'https:',
        _redirectable: Writable {
          _writableState: WritableState {
            objectMode: false,
            highWaterMark: 16384,
            finalCalled: false,
            needDrain: false,
            ending: false,
            ended: false,
            finished: false,
            destroyed: false,
            decodeStrings: true,
            defaultEncoding: 'utf8',
            length: 0,
            writing: false,
            corked: 0,
            sync: true,
            bufferProcessing: false,
            onwrite: [Function: bound onwrite],
            writecb: null,
            writelen: 0,
            afterWriteTickInfo: null,
            buffered: [],
            bufferedIndex: 0,
            allBuffers: true,
            allNoop: true,
            pendingcb: 0,
            constructed: true,
            prefinished: false,
            errorEmitted: false,
            emitClose: true,
            autoDestroy: true,
            errored: null,
            closed: false,
            closeEmitted: false,
            [Symbol(kOnFinished)]: []
          },
          _events: [Object: null prototype] {
            response: [Function: handleResponse],
            error: [Function: handleRequestError],
            socket: [Array]
          },
          _eventsCount: 3,
          _maxListeners: undefined,
          _options: {
            maxRedirects: 21,
            maxBodyLength: Infinity,
            protocol: 'https:',
            path: '/streams/evm',
            method: 'PUT',
            headers: [Object: null prototype],
            agents: [Object],
            auth: undefined,
            beforeRedirect: [Function: dispatchBeforeRedirect],
            beforeRedirects: [Object],
            hostname: 'api.moralis-streams.com',
            port: '',
            agent: undefined,
            nativeProtocols: [Object],
            pathname: '/streams/evm'
          },
          _ended: true,
          _ending: true,
          _redirectCount: 0,
          _redirects: [],
          _requestBodyLength: 15338,
          _requestBodyBuffers: [],
          _onNativeResponse: [Function (anonymous)],
          _currentRequest: [Circular *2],
          _currentUrl: 'https://api.moralis-streams.com/streams/evm',
          _timeout: null,
          [Symbol(kCapture)]: false
        },
        [Symbol(kCapture)]: false,
        [Symbol(kNeedDrain)]: false,
        [Symbol(corked)]: 0,
        [Symbol(kOutHeaders)]: [Object: null prototype] {
          accept: [ 'Accept', 'application/json, text/plain, */*' ],
          'content-type': [ 'Content-Type', 'application/json' ],
          'x-moralis-platform': [ 'x-moralis-platform', 'NodeJS SDK' ],
          'x-moralis-platform-version': [ 'x-moralis-platform-version', '2.19.0' ],
          'x-moralis-build-target': [ 'x-moralis-build-target', 'node' ],
          'x-api-key': [
            'x-api-key',
            'all3RzGKuVBfOjmsNNW1w4NEmSALcqdKeYG4K6SXlGQZPp4nPpsenLEVdahKBrZQ'
          ],
          'user-agent': [ 'User-Agent', 'axios/1.3.6' ],
          'content-length': [ 'Content-Length', '15338' ],
          'accept-encoding': [ 'Accept-Encoding', 'gzip, compress, deflate, br' ],
          host: [ 'Host', 'api.moralis-streams.com' ]
        },
        [Symbol(kUniqueHeaders)]: null
      },
      data: { message: 'Invalid chainId: 0x[object Object]' }
    }
  }
}
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

If I change the chainId to '0x13881' = chainID.testNet the app runs again and when I enter the url /streams-webhook the app does not stop, but the error appears again in the Not Moralis log

according to the log:

aqui1
aqui2
aqui3
aqui4
not moralis

it stays here:

    Moralis.Streams.verifySignature({
      body,
      signature: headers["x-signature"],
    })

There are some changes required in your code.

To receive webhook data from moralis you need to use the post request, only then you will be able to read the req.body. Your code is returning not moralis as the req.body is null in GET route endpoint.

In your app.get the route you have also used Moralis.Streams.add function this should be called only once unless you want to create multiple streams. So move it out from the streams-webhook endpoint.

I had not realized this, because my api was blocked?