facing error of no matching event in my aws lambda console and my code is correct but getting error

{
“time”: “2024-06-18T11:04:04.664Z”,
“type”: “platform.start”,
“record”: {
“requestId”: “c6355bdf-2df5-4472-90f2-44bb5aa00de6”,
“version”: “$LATEST”,
“tracing”: {
“spanId”: “2b2155005d3aa009”,
“type”: “X-Amzn-Trace-Id”,
“value”: “Root=1-667169a4-29e7ef1e582d58890db8c36b;Parent=009e9a0e10725932;Sampled=1”
}
}
}
{
“timestamp”: “2024-06-18T11:04:04.834Z”,
“level”: “INFO”,
“requestId”: “c6355bdf-2df5-4472-90f2-44bb5aa00de6”,
“message”: “decoding Body…”
}
{
“timestamp”: “2024-06-18T11:04:04.834Z”,
“level”: “INFO”,
“requestId”: “c6355bdf-2df5-4472-90f2-44bb5aa00de6”,
“message”: “{“confirmed”:true,“chainId”:“0x61”,“abi”:[{“name”:“Initialized”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“uint64”,“name”:“version”,“indexed”:false}]},{“name”:“OwnershipTransferred”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“address”,“name”:“previousOwner”,“indexed”:true},{“type”:“address”,“name”:“newOwner”,“indexed”:true}]},{“name”:“ParticipantEntered”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“address”,“name”:“participant”,“indexed”:true}]},{“name”:“PrizeWithdrawn”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“address”,“name”:“participant”,“indexed”:true},{“type”:“uint256”,“name”:“amount”,“indexed”:false}]},{“name”:“PrizesDistributed”,“type”:“event”,“anonymous”:false,“inputs”:[]},{“name”:“Upgraded”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“address”,“name”:“implementation”,“indexed”:true}]}],“streamId”:“4a12d1b0-af9d-4072-b80c-f50405ab1c3b”,“tag”:“RegistrationTransactionLottery”,“retries”:0,“block”:{“number”:“41330147”,“hash”:“0xf4b5246637271eaed1c618016453069fc1b55ad35c3793309cfdb0befa05e352”,“timestamp”:“1718708588”},“logs”:[{“logIndex”:“12”,“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“address”:“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“data”:“0x”,“topic0”:“0xef3b3ae531a4f494c95e537ec1fe385cfe5c1146cb4c1d850b24bad385958049”,“topic1”:“0x0000000000000000000000007fefe940bdc393552a0b8743048a2ee5a20abaf9”,“topic2”:null,“topic3”:null,“triggered_by”:[“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”]},{“logIndex”:“10”,“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“address”:“0x82a6417ea50a561b6ebd281cf000a62351034b5c”,“data”:“0x0000000000000000000000000000000000000000000000008ac7230489e80000”,“topic0”:“0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef”,“topic1”:“0x0000000000000000000000007fefe940bdc393552a0b8743048a2ee5a20abaf9”,“topic2”:“0x000000000000000000000000f2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“topic3”:null,“triggered_by”:null},{“logIndex”:“11”,“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“address”:“0x82a6417ea50a561b6ebd281cf000a62351034b5c”,“data”:“0x0000000000000000000000000000000000000000000000008ac7230489e80000”,“topic0”:“0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925”,“topic1”:“0x000000000000000000000000f2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“topic2”:“0x000000000000000000000000f2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“topic3”:null,“triggered_by”:null}],“txs”:[],“txsInternal”:[],“erc20Transfers”:[{“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“logIndex”:“10”,“contract”:“0x82a6417ea50a561b6ebd281cf000a62351034b5c”,“triggered_by”:null,“from”:“0x7fefe940bdc393552a0b8743048a2ee5a20abaf9”,“to”:“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“value”:“10000000000000000000”,“tokenName”:“MLM”,“tokenSymbol”:“USDT”,“tokenDecimals”:“18”,“logo”:”",“thumbnail”:"",“possibleSpam”:false,“verifiedCollection”:false,“valueWithDecimals”:“10”}],“erc20Approvals”:[{“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“logIndex”:“11”,“contract”:“0x82a6417ea50a561b6ebd281cf000a62351034b5c”,“triggered_by”:null,“owner”:“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“spender”:“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“value”:“10000000000000000000”,“tokenName”:“MLM”,“tokenSymbol”:“USDT”,“tokenDecimals”:“18”,“logo”:"",“thumbnail”:"",“possibleSpam”:false,“verifiedCollection”:false,“valueWithDecimals”:“10”}],“nftTokenApprovals”:[],“nftApprovals”:{“ERC721”:[],“ERC1155”:[]},“nftTransfers”:[],“nativeBalances”:[]}"
}
{
“timestamp”: “2024-06-18T11:04:04.917Z”,
“level”: “ERROR”,
“requestId”: “c6355bdf-2df5-4472-90f2-44bb5aa00de6”,
“message”: “ERROR Error: no matching event (argument=“topichash”, value=“0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef”, code=INVALID_ARGUMENT, version=abi/5.7.0)\n at Logger.makeError (/var/task/node_modules/@ethersproject/logger/lib/index.js:238:21)\n at Logger.throwError (/var/task/node_modules/@ethersproject/logger/lib/index.js:247:20)\n at Logger.throwArgumentError (/var/task/node_modules/@ethersproject/logger/lib/index.js:250:21)\n at Interface.getEvent (/var/task/node_modules/@ethersproject/abi/lib/interface.js:216:20)\n at LogParser.read (/var/task/node_modules/@moralisweb3/streams/lib/cjs/index.cjs:620:47)\n at /var/task/node_modules/@moralisweb3/streams/lib/cjs/index.cjs:833:41\n at Array.forEach ()\n at parseLog (/var/task/node_modules/@moralisweb3/streams/lib/cjs/index.cjs:832:10)\n at Streams._this.parsedLogs (/var/task/node_modules/@moralisweb3/streams/lib/cjs/index.cjs:956:60)\n at exports.handler (/var/task/app.js:136:39) {\n reason: ‘no matching event’,\n code: ‘INVALID_ARGUMENT’,\n argument: ‘topichash’,\n value: ‘0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef’\n}”,
“errorType”: “Error”,
“errorMessage”: “no matching event (argument=“topichash”, value=“0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef”, code=INVALID_ARGUMENT, version=abi/5.7.0)”,
“stackTrace”: [
“Error: no matching event (argument=“topichash”, value=“0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef”, code=INVALID_ARGUMENT, version=abi/5.7.0)”,
" at Logger.makeError (/var/task/node_modules/@ethersproject/logger/lib/index.js:238:21)",
" at Logger.throwError (/var/task/node_modules/@ethersproject/logger/lib/index.js:247:20)",
" at Logger.throwArgumentError (/var/task/node_modules/@ethersproject/logger/lib/index.js:250:21)",
" at Interface.getEvent (/var/task/node_modules/@ethersproject/abi/lib/interface.js:216:20)",
" at LogParser.read (/var/task/node_modules/@moralisweb3/streams/lib/cjs/index.cjs:620:47)",
" at /var/task/node_modules/@moralisweb3/streams/lib/cjs/index.cjs:833:41",
" at Array.forEach ()",
" at parseLog (/var/task/node_modules/@moralisweb3/streams/lib/cjs/index.cjs:832:10)",
" at Streams._this.parsedLogs (/var/task/node_modules/@moralisweb3/streams/lib/cjs/index.cjs:956:60)",
" at exports.handler (/var/task/app.js:136:39)"
]
}
{
“timestamp”: “2024-06-18T11:04:04.917Z”,
“level”: “ERROR”,
“requestId”: “c6355bdf-2df5-4472-90f2-44bb5aa00de6”,
“message”: “ERRORINFO {\n body: '{“confirmed”:true,“chainId”:“0x61”,“abi”:[{“name”:“Initialized”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“uint64”,“name”:“version”,“indexed”:false}]},{“name”:“OwnershipTransferred”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“address”,“name”:“previousOwner”,“indexed”:true},{“type”:“address”,“name”:“newOwner”,“indexed”:true}]},{“name”:“ParticipantEntered”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“address”,“name”:“participant”,“indexed”:true}]},{“name”:“PrizeWithdrawn”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“address”,“name”:“participant”,“indexed”:true},{“type”:“uint256”,“name”:“amount”,“indexed”:false}]},{“name”:“PrizesDistributed”,“type”:“event”,“anonymous”:false,“inputs”:[]},{“name”:“Upgraded”,“type”:“event”,“anonymous”:false,“inputs”:[{“type”:“address”,“name”:“implementation”,“indexed”:true}]}],“streamId”:“4a12d1b0-af9d-4072-b80c-f50405ab1c3b”,“tag”:“RegistrationTransactionLottery”,“retries”:0,“block”:{“number”:“41330147”,“hash”:“0xf4b5246637271eaed1c618016453069fc1b55ad35c3793309cfdb0befa05e352”,“timestamp”:“1718708588”},“logs”:[{“logIndex”:“12”,“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“address”:“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“data”:“0x”,“topic0”:“0xef3b3ae531a4f494c95e537ec1fe385cfe5c1146cb4c1d850b24bad385958049”,“topic1”:“0x0000000000000000000000007fefe940bdc393552a0b8743048a2ee5a20abaf9”,“topic2”:null,“topic3”:null,“triggered_by”:[“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”]},{“logIndex”:“10”,“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“address”:“0x82a6417ea50a561b6ebd281cf000a62351034b5c”,“data”:“0x0000000000000000000000000000000000000000000000008ac7230489e80000”,“topic0”:“0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef”,“topic1”:“0x0000000000000000000000007fefe940bdc393552a0b8743048a2ee5a20abaf9”,“topic2”:“0x000000000000000000000000f2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“topic3”:null,“triggered_by”:null},{“logIndex”:“11”,“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“address”:“0x82a6417ea50a561b6ebd281cf000a62351034b5c”,“data”:“0x0000000000000000000000000000000000000000000000008ac7230489e80000”,“topic0”:“0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925”,“topic1”:“0x000000000000000000000000f2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“topic2”:“0x000000000000000000000000f2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“topic3”:null,“triggered_by”:null}],“txs”:[],“txsInternal”:[],“erc20Transfers”:[{“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“logIndex”:“10”,“contract”:“0x82a6417ea50a561b6ebd281cf000a62351034b5c”,“triggered_by”:null,“from”:“0x7fefe940bdc393552a0b8743048a2ee5a20abaf9”,“to”:“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“value”:“10000000000000000000”,“tokenName”:“MLM”,“tokenSymbol”:“USDT”,“tokenDecimals”:“18”,“logo”:”",“thumbnail”:"",“possibleSpam”:false,“verifiedCollection”:false,“valueWithDecimals”:“10”}],“erc20Approvals”:[{“transactionHash”:“0xcec447c38b4264306a5f44b660604fc4700a34d2d7ab5ac62a722393851a8d24”,“logIndex”:“11”,“contract”:“0x82a6417ea50a561b6ebd281cf000a62351034b5c”,“triggered_by”:null,“owner”:“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“spender”:“0xf2d69e091670fc85b0fddea8ee3ed3f4e42eb445”,“value”:“10000000000000000000”,“tokenName”:“MLM”,“tokenSymbol”:“USDT”,“tokenDecimals”:“18”,“logo”:"",“thumbnail”:"",“possibleSpam”:false,“verifiedCollection”:false,“valueWithDecimals”:“10”}],“nftTokenApprovals”:[],“nftApprovals”:{“ERC721”:[],“ERC1155”:[]},“nftTransfers”:[],“nativeBalances”:[]}’,\n createdAt: ‘2024-06-18 11:04:04.0834’\n}"
}
{
“time”: “2024-06-18T11:04:05.134Z”,
“type”: “platform.report”,
“record”: {
“requestId”: “c6355bdf-2df5-4472-90f2-44bb5aa00de6”,
“metrics”: {
“durationMs”: 469.848,
“billedDurationMs”: 470,
“memorySizeMB”: 128,
“maxMemoryUsedMB”: 110
},
“tracing”: {
“spanId”: “2b2155005d3aa009”,
“type”: “X-Amzn-Trace-Id”,
“value”: “Root=1-667169a4-29e7ef1e582d58890db8c36b;Parent=009e9a0e10725932;Sampled=1”
},
“status”: “success”
}
} this is aws console log for lambda events, providing my code also “const MongoClient = require(“mongodb”).MongoClient
const { Streams } = require(”@moralisweb3/streams")
const { Core } = require("@moralisweb3/common-core")

const core = Core.create()
core.registerModules([Streams])
const streams = core.getModule(Streams.moduleName)

const response = {
statusCode: 200,
body: JSON.stringify({
message: “Data saved Successfully”,
}),
};

const MONGODB_URL = process.env.DBURI
let cachedDB = null;

async function connectToDatabase() {
try {
if (cachedDB) {
return true;
}
console.log(“creating mongodb client”);
const client = await MongoClient.connect(MONGODB_URL);
if(client){
cachedDB = client.db(process.env.DBNAME);
console.log(‘Connected to DB!’);
return true;
}else{
console.error(‘Unable to connect to DB!’);
return false;
}
} catch (err) {
console.log(“Unable to connecte to DB try again”);
return false;
}
}

/** Return fromated date
@returns {String} datetime return current date time in yyyy-mm-dd hh:mm:ss formate
*/
function getCurrentDateTime() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, “0”);
const day = String(now.getDate()).padStart(2, “0”);
const hours = String(now.getHours()).padStart(2, “0”);
const minutes = String(now.getMinutes()).padStart(2, “0”);
const seconds = String(now.getSeconds()).padStart(2, “0”);
const milliseconds = String(now.getMilliseconds()).padStart(4,“0”);

const formattedDateTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}`;
return formattedDateTime;

}

async function saveTransaction(body, decodedLogs){
const currentDT = getCurrentDateTime();
const transaction = {
raw: body,
decoded: decodedLogs,
createdAt: currentDT
};
try {
const result = await cachedDB.collection(“LotteryRegistration”).insertOne(transaction);
if(result){
console.log(“saved transaction”);
return result;
}else{
console.error(“failed to save transaction”, body);
return false;
}
} catch (err) {
console.error(“failed to save transaction”);
console.error(transaction);
return false;
}
}
async function saveTransactionFalse(body, decodedLogs) {
const currentDT = getCurrentDateTime();
const transaction = {
raw: body,
decoded: decodedLogs,
createdAt: currentDT
};
try {
const result = await cachedDB.collection(“nonconfirmtransactions”).insertOne(transaction);
if (result) {
console.log(“saved nonconfirm transaction”);
return result;
} else {
console.error(“failed to save nonconfirm transaction”, body);
return false;
}
} catch (err) {
console.error(“failed to save nonconfirm transaction”);
console.error(transaction);
return false;
}
}

async function transactionAlreadyExist(blockhash){
const result = await cachedDB.collection(‘LotteryRegistration’).findOne({“raw.block.hash”:blockhash});
if(result){
return true;
}
return false
}

exports.handler = async (event, context ) => {
context.callbackWaitsForEmptyEventLoop = false;
const currentDT = getCurrentDateTime();
try {

console.log("decoding  Body...")
// console.log(event.body);
const body = JSON.parse(event.body);
console.log("🚀 ~ exports.handler= ~ body:", body)
// const decodedLogs = await streams.parsedLogs(body);
// console.log("🚀 ~ exports.handler= ~ decodedLogs:", decodedLogs)
const decodedLogs = await streams.parsedLogs(body).catch(err => {
  console.error("Error parsing logs:", err);
  throw err;

});

const currentDoc = {
  body:JSON.stringify(event.body),
  decoded:decodedLogs,
  currentTime: currentDT,
};
console.log("Decoded:", currentDoc);
console.log("Connecting to DB....")
let i = 0;
while (!await connectToDatabase() && i < 5) {
  console.log("Trying to connect to Db" + i.toString())
  i++
}

if(body.confirmed == true && body.tag == "RegistrationTransactionLottery"){
  // for (const log of body.logs) {
  //   const transactionExists = await transactionAlreadyExist(log.transactionHash);

  //   if (transactionExists) {
  //     console.log("Transaction already exists, skipping insertion", log.transactionHash);
  //     // return { statusCode: 200, body: JSON.stringify({ message: "Transaction already exists" }) }; // Return response and skip saving transaction
  //     return response
  //   }
  // }
  for (const log of body.logs) {
    const transactionExists = await transactionAlreadyExist(log.transactionHash);
    console.log("🚀 ~ exports.handler= ~ transactionExists:", transactionExists)

    if (transactionExists) {
      console.log("Transaction already exists, skipping insertion", log.transactionHash);
      // return { statusCode: 200, body: JSON.stringify({ message: "Transaction already exists" }) }; // Return response and skip saving transaction
      console.log(log.transactionHash)
      return response
    }
  } 
  const result = await saveTransaction(body, decodedLogs)
  console.log("🚀 ~ exports.handler= ~ result:", result)
  for (let i = 0; i < decodedLogs.length; i++){
    let data = decodedLogs[i]
    let  lottery = {
      // from: "millionaire_royalty",
      // to: data.user,
      // type: "millionaire-royalty",
      transaction_id: result.insertedId,
      // amount: Math.ceil(parseInt(data.amount) / 1000000000000000000),
      // createdAt: currentDT,
      // updatedAt: currentDT,
    }  
    const userDetails = await cachedDB.collection("LotteryRegisterUsers").insertOne(lottery)
    console.log("🚀 ~ exports.handler= ~ userEarning:", userDetails)
    if (userDetails) {
      console.log("Lottery registration successfully!!")   
}

}
}else if(body.tag == “RegistrationTransactionLottery”) {
await saveTransactionFalse(body,decodedLogs)
console.error("Registration failed ", body);
}else {
console.error(“Registration Failed…”, body);
}
return response
} catch (error) {

console.error("ERROR", error);
const errInfo = {
  body: event.body,
  createdAt: currentDT
}
console.error("ERRORINFO", errInfo);
// return response;
return { statusCode: 500, body: JSON.stringify({ message: "Internal Server Error" }) }

}
};"This text will be hidden

Hi @bhavesh

Is “No matching event” error thrown by your code or the Moralis SDK?

Can you paste just the code related to it in backticks?

that error shows an ABI-event mismatch. The topic hash 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef corresponds to the ERC20 Transfer event signature, that’s missing in your current ABI.