you will see that screen when the api key is blocked, it could be blocked when reaching the daily limit, when the api key is blocked streams api will not work
yes thanks I was able to fix it.
Ok if I separated the start of a stream from the stream route and I already created the stream, I verified it in the moralis interface and it worked, but now in the stream route that is configured in moralis https://xxxx-xxx-xxx- xx-xxx.ngrok.io/streams-webhook
, it’s the same as the stream, I execute the smart contract, to see if the event receives it, I refresh the url and it keeps giving me the same not moralis
error. I leave the code that I have at the moment, thank you very much:
app.get("/streams-webhook", async (req: any, res: any) => {
try {
const { headers, body, tag }: any = req;
console.log('aqui2', );
const webhook: Types.IWebhook = req.body;
console.log('aqui3', );
Moralis.Streams.verifySignature({
body,
signature: headers["x-signature"],
});
console.log('aqui4', );
return res.status(200).json();
} catch (e) {
console.log("Not Moralis", e);
return res.status(400).json();
}
})
what is the error?
did you set the right API key?
is the validation signature that fails or something else?
now it says, yes have right key,log: Not Moralis MoralisError [Moralis Stream Error]: [S0004]signature is not valid
, yes its about validation signature
we can help with regenerating the api key if needed, you can double check the api key
if it is the same api key that is configured in the backend. yes of course. Thank you very much. Will I solve the error?
This error should be easy to solve. You can send an email to [email protected] to regenerate the api key and check after that with the new api key.
hello how are you, i already reset the apikey but now i try to create a new stream, and it throws me this error:
error MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Bad Request(400): Could not POST to https://xxxx-xxx-xxx-xx-xxx.ngrok.io/streams-webhook - Request failed with status code 401. Please check your webhook URL. Request failed with status code 401. Please check your webhook URL.
at RequestController.makeError
create stream:
app.get("/AuctionCreated", async (req: any, res: any) => {
try{
const stream = await Moralis.Streams.add({
chains: [chainID.testNet],
description: 'AuctionsCreated721',
tag: 'AuctionsCreated',
webhookUrl: `${url}${config.STREAMS_WEBHOOK_URL}`,
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({
id,
address,
});
return res.status(200).json();
}catch(error){
console.log('error', error)
return res.status(400).json(error);
}
})
call request stream :
app.get("/streams-webhook", async (req: any, res: any) => {
try {
const { headers, body, tag }: any = req;
console.log('body', body);
console.log('aqui2');
const webhook: Types.IWebhook = req.body;
console.log('aqui3');
Moralis.Streams.verifySignature({
body,
signature: headers["x-signature"],
});
console.log('aqui4');
return res.status(200).json();
} catch (e) {
console.log("Not Moralis", e);
return res.status(400).json();
}
})
I verify that the stream is the same https://xxxx-xxx-xxx-xx-xxx.ngrok.io/streams-webhook
and in the log
This is an error from the webhook. Happens when the response is not sent from your server. Check your console logs if there is an error.
Hi John, yes, here is the complete error log:
error MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Bad Request(400): Could not POST to https://fc94-143-255-84-147.ngrok.io/streams-webhook - Request failed with status code 401. Please check your webhook URL.
at RequestController.makeError (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:1226:20)
at RequestController.<anonymous> (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:1207:38)
at step (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:85:23)
at Object.throw (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:66:53)
at rejected (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:57:65)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
isMoralisError: true,
code: 'C0006',
details: {
status: 400,
response: {
status: 400,
statusText: 'Bad Request',
headers: [AxiosHeaders],
config: [Object],
request: [ClientRequest],
data: [Object]
}
},
[cause]: AxiosError: Request failed with status code 400
at settle (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\axios\lib\core\settle.js:19:12)
at IncomingMessage.handleStreamEnd (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\axios\lib\adapters\http.js:556:11)
at IncomingMessage.emit (node:events:525:35)
at IncomingMessage.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ERR_BAD_REQUEST',
config: {
transitional: [Object],
adapter: [Array],
transformRequest: [Array],
transformResponse: [Array],
timeout: 20000,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: Infinity,
maxBodyLength: Infinity,
env: [Object],
validateStatus: [Function: validateStatus],
headers: [AxiosHeaders],
method: 'put',
url: 'https://api.moralis-streams.com/streams/evm',
params: {},
data: '{"webhookUrl":"https://fc94-143-255-84-147.ngrok.io/streams-webhook","description":"AuctionsCreated721","tag":"AuctionsCreated","topic0":["AuctionCreated(address,uint256,uint8,uint256,uint256,uint256,address)","NftAuctionCreated(address,uint256,address,address,uint128,uint128,uint32,uint32,address[],uint32[])"],"includeContractLogs":true,"chainIds":["0x13881"],"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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"},{"inputs":[{"internalType":"address","name":"_nftContractAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_erc20Token","type":"address"},{"internalType":"uint128","name":"_minPrice","type":"uint128"},{"internalType":"uint128","name":"_buyNowPrice","type":"uint128"},{"internalType":"address[]","name":"_feeRecipients","type":"address[]"},{"internalType":"uint32[]","name":"_feePercentages","type":"uint32[]"}],"name":"createDefaultNftAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContractAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_erc20Token","type":"address"},{"internalType":"uint128","name":"_minPrice","type":"uint128"},{"internalType":"uint128","name":"_buyNowPrice","type":"uint128"},{"internalType":"uint32","name":"_auctionBidPeriod","type":"uint32"},{"internalType":"uint32","name":"_bidIncreasePercentage","type":"uint32"},{"internalType":"address[]","name":"_feeRecipients","type":"address[]"},{"internalType":"uint32[]","name":"_feePercentages","type":"uint32[]"}],"name":"createNewNftAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContractAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_erc20Token","type":"address"},{"internalType":"uint128","name":"_buyNowPrice","type":"uint128"},{"internalType":"address","name":"_whitelistedBuyer","type":"address"},{"internalType":"address[]","name":"_feeRecipients","type":"address[]"},{"internalType":"uint32[]","name":"_feePercentages","type":"uint32[]"}],"name":"createSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAuctionBidPeriod","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultBidIncreasePercentage","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContractAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getERC20Token","outputs":[{"internalType":"address","name":"","type":"ad'... 5328 more characters
},
request: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: [TLSSocket],
_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: 8dXhfvSVVcJIN8KrNyD7jMWRdoxut8UOZrsLVg16VblGlL2jFOLEZluXfxvnxab0\r\n' +
'User-Agent: axios/1.3.6\r\n' +
'Content-Length: 15328\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],
socketPath: undefined,
method: 'PUT',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/streams/evm',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'api.moralis-streams.com',
protocol: 'https:',
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(kUniqueHeaders)]: null
},
response: {
status: 400,
statusText: 'Bad Request',
headers: [AxiosHeaders],
config: [Object],
request: [ClientRequest],
data: [Object]
}
}
}
C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\parse-server\lib\ParseServer.js:261
throw err;
^
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'ClientRequest'
| property 'socket' -> object with constructor 'TLSSocket'
--- property '_httpMessage' closes the circle
at JSON.stringify (<anonymous>)
at stringify (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\express\lib\response.js:1150:12)
at ServerResponse.json (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\express\lib\response.js:271:14)
at C:\Users\david\Documents\Programacion\react\Koolinart\backend\src\index.ts:108:28
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS C:\Users\david\Documents\Programacion\react\Koolinart\backend> yarn dev
yarn run v1.22.19
warning ..\package.json: No license field
$ ts-node src/index.ts
warn: DeprecationWarning: The Parse Server option 'directAccess' default will change to 'true' in a future version. Additionally, the environment variable 'PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS' will be deprecated and renamed to 'PARSE_SERVER_DIRECT_ACCESS' in a future version; it is currently possible to use either one.
warn: DeprecationWarning: The Parse Server option 'enforcePrivateUsers' default will change to 'true' in a future version.
warn: DeprecationWarning: The Parse Server option 'allowClientClassCreation' default will change to 'false' in a future version.
config.MORALIS_API_KEY 8dXhfvSVVcJIN8KrNyD7jMWRdoxut8UOZrsLVg16VblGlL2jFOLEZluXfxvnxab0
info: Parse LiveQuery Server started running
Moralis Server is running on port 1337 and stream webhook url https://f9da-143-255-84-147.ngrok.io/streams-webhook
STREAMS_WEBHOOK_URL https://f9da-143-255-84-147.ngrok.io/streams-webhook
error MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Bad Request(400): Could not POST to https://f9da-143-255-84-147.ngrok.io/streams-webhook - Request failed with status code 401. Please check your webhook URL.
at RequestController.makeError (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:1226:20)
at RequestController.<anonymous> (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:1207:38)
at step (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:85:23)
at Object.throw (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:66:53)
at rejected (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\moralis\node_modules\@moralisweb3\common-core\lib\cjs\index.cjs:57:65)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
isMoralisError: true,
code: 'C0006',
details: {
status: 400,
response: {
status: 400,
statusText: 'Bad Request',
headers: [AxiosHeaders],
config: [Object],
request: [ClientRequest],
data: [Object]
}
},
[cause]: AxiosError: Request failed with status code 400
at settle (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\axios\lib\core\settle.js:19:12)
at IncomingMessage.handleStreamEnd (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\axios\lib\adapters\http.js:556:11)
at IncomingMessage.emit (node:events:525:35)
at IncomingMessage.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ERR_BAD_REQUEST',
config: {
transitional: [Object],
adapter: [Array],
transformRequest: [Array],
transformResponse: [Array],
timeout: 20000,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: Infinity,
maxBodyLength: Infinity,
env: [Object],
validateStatus: [Function: validateStatus],
headers: [AxiosHeaders],
method: 'put',
url: 'https://api.moralis-streams.com/streams/evm',
params: {},
data: '{"webhookUrl":"https://f9da-143-255-84-147.ngrok.io/streams-webhook","description":"AuctionsCreated721","tag":"AuctionsCreated","topic0":["AuctionCreated(address,uint256,uint8,uint256,uint256,uint256,address)","NftAuctionCreated(address,uint256,address,address,uint128,uint128,uint32,uint32,address[],uint32[])"],"includeContractLogs":true,"chainIds":["0x13881"],"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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"},
},
request: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: [TLSSocket],
_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: 8dXhfvSVVcJIN8KrNyD7jMWRdoxut8UOZrsLVg16VblGlL2jFOLEZluXfxvnxab0\r\n' +
'User-Agent: axios/1.3.6\r\n' +
'Content-Length: 15328\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],
socketPath: undefined,
method: 'PUT',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/streams/evm',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'api.moralis-streams.com',
protocol: 'https:',
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(kUniqueHeaders)]: null
},
[{"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"},{"inputs":[{"internalType":"address","name":"_nftContractAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_erc20Token","type":"address"},{"internalType":"uint128","name":"_minPrice","type":"uint128"},{"internalType":"uint128","name":"_buyNowPrice","type":"uint128"},{"internalType":"address[]","name":"_feeRecipients","type":"address[]"},{"internalType":"uint32[]","name":"_feePercentages","type":"uint32[]"}],"name":"createDefaultNftAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContractAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_erc20Token","type":"address"},{"internalType":"uint128","name":"_minPrice","type":"uint128"},{"internalType":"uint128","name":"_buyNowPrice","type":"uint128"},{"internalType":"uint32","name":"_auctionBidPeriod","type":"uint32"},{"internalType":"uint32","name":"_bidIncreasePercentage","type":"uint32"},{"internalType":"address[]","name":"_feeRecipients","type":"address[]"},{"internalType":"uint32[]","name":"_feePercentages","type":"uint32[]"}],"name":"createNewNftAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContractAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_erc20Token","type":"address"},{"internalType":"uint128","name":"_buyNowPrice","type":"uint128"},{"internalType":"address","name":"_whitelistedBuyer","type":"address"},{"internalType":"address[]","name":"_feeRecipients","type":"address[]"},{"internalType":"uint32[]","name":"_feePercentages","type":"uint32[]"}],"name":"createSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAuctionBidPeriod","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultBidIncreasePercentage","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContractAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getERC20Token","outputs":[{"internalType":"address","name":"","type":"ad'... 5328 more characters
},
request: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: [TLSSocket],
_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: 8dXhfvSVVcJIN8KrNyD7jMWRdoxut8UOZrsLVg16VblGlL2jFOLEZluXfxvnxab0\r\n' +
'User-Agent: axios/1.3.6\r\n' +
'Content-Length: 15328\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],
socketPath: undefined,
method: 'PUT',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/streams/evm',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'api.moralis-streams.com',
protocol: 'https:',
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(kUniqueHeaders)]: null
},
response: {
status: 400,
statusText: 'Bad Request',
headers: [AxiosHeaders],
config: [Object],
request: [ClientRequest],
data: [Object]
}
}
}
^
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'ClientRequest'
| property 'socket' -> object with constructor 'TLSSocket'
--- property '_httpMessage' closes the circle
at JSON.stringify (<anonymous>)
at stringify (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\express\lib\response.js:1150:12)
at ServerResponse.json (C:\Users\david\Documents\Programacion\react\Koolinart\backend\node_modules\express\lib\response.js:271:14)
at C:\Users\david\Documents\Programacion\react\Koolinart\backend\src\index.ts:109:28
at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This part seems like error from your code. Can you check what is cauing this error? Try adding some logs to check which JSON is causing this error.
I guess the json is the one from the stream. I don’t have any more json in the code. It’s the same one that worked:
app.get("/AuctionCreated", async (req: any, res: any) => {
console.log("STREAMS_WEBHOOK_URL", `${url}${config.STREAMS_WEBHOOK_URL}`)
const webHookUrl = `${url}${config.STREAMS_WEBHOOK_URL}`
try{
const stream = await Moralis.Streams.add({
chains: [chainID.testNet],
description: 'AuctionsCreated721',
tag: 'AuctionsCreated',
webhookUrl: webHookUrl,
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({
address,
id
});
return res.status(200).json();
}catch(error){
console.log('error', error)
return res.status(400).json(error);
}
})
You can get this error sometimes when an object variable is used instead of a value as a parameter to a function
Well, what I understand about the error, according to the error that is in the log (the error is very extensive) error: ode:
'C0006',
details: {
status: 422,
reply: {
status: 422,
statusText: 'Unprocessable Entity',
headers: [AxiosHeaders],
config: [Object],
request: [ClientRequest],
data: [Object]
}
},
[cause]: AxiosError: Request failed with status code 422
It is that as John said that he cannot read the url, because I tried it from the code, and it gives me error c0006
and from what I can read is that the ngrok url does not communicate, because in the same way I go to the moralis interface , and I try to create the stream and it also gives me an error
Something went wrong!
Could not POST to https://664f-143-255-84-146.ngrok.io/streams-webhook - Request failed with status code 401. Please check your webhook URL.
And if indeed when running the moralis server it is the url that the server gives me. So the serious question is, if before they reset the apikey it worked and now it gives an error on both sides, what should I do, I shared the code, it’s small even in the documentation.
If you have already updated the API key in your code then it is not related to the API key.
One thing I noticed is your /streams-webhook
endpoint is still defined as a GET api route. This should be defined as a POST api route so that Moralis streams data can be posted to your webhook.
I am not sure why the error code says 422 in the error. Check this error code details if it relates to something.
https://www.rfc-editor.org/rfc/rfc4918#section-11.2
Try adding some console.logs to debug more on what is causing the error.
How can I configure the moralis ngrok token? What I can notice from everything I’ve tried is that ngrok doesn’t generate connecting urls for me. and it gives me this error when trying to open the url
You didn’t create an account for ngrok?
if you mean download the ngrok exe and configure the auth token ngrok config add-authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
yes I did. but it keeps telling me the same thing
you start moralis server with a local webhook url that is not accessible from the internet, then you use ngrok to proxy external traffic to that local port and server