Get transaction events

Hi,

Me again. So I noticed I cannot get TX events in Moralis like in Hardhat. There is this topic here to use Moralis.Web3API instead.

But I also noticed there is Moralis.Web3Events thingy too. So my question is…

How do I actually get the first event (or by name) of the TX assuming this:

          const mintingTx = await Moralis.executeFunction(this.contractOptions);
          const minedTx = await mintingTx.wait();

those things seem unrelated, from that code it looks like you want to send a transaction to blockchain, first you have to get at least the transaction hash for that transaction, and after that you could get more information about that transaction also with web3api calls

Hello @cryptokid, you’re always awake, I love you! :rofl:

So I think my question was asked wrong. And maybe that’s not the issue with Moralis, but working with a live network instead of hardhat.

Because I’m able to get the events, particularly event[0]

With with Hardhat I’m able to get what I need from a transaction with:

    const mintingTx = await owItem.connect(players[1]).mintItem(50);
    const minted = await mintingTx.wait();
    const eventTransferSingle = minted.events[0];
    tokenIdB = parseInt(eventTransferSingle.args.id);

With Moralis on a live AVAX Fuji C-Chain I get using similar:

    const mintingTx = await Moralis.executeFunction(this.contractOptions);
    const mined = await mintingTx.wait();
    const eventTransferSingle = mined.events[0];
    // eventTransferSingle already returns a different object
    let tokenIdB = parseInt(eventTransferSingle.args);
    // so eventTransferSingle is NaN

Does this make sense?

Ok I need more time to investigae that, as I probably didn’t read your reply I need to. Goodnight, hopefully I will look again at the problem in the morning from a different perspective! :grin:

So the issue was, that I had to pass in the event from the ABI. And instead I only had the ABI part for the function in my contractOptions