question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] why do some events from contract.queryfilter not contain event/args fields?

See original GitHub issue

Hi, when using Contract.queryFilter like this:

let eventFilter = [myContract.filters.Transfer()];
let events = await myContract.queryFilter(eventFilter, start, end);

I will get some events in the result which have more fields, for example:

{
      blockNumber: 10789332,
      blockHash: '0xfbe6daf633495f2a93cbf5bc1a6689e0706988f99a880a50737a6cbf97c6382c',
      transactionIndex: 87,
      removed: false,
      address: '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643',
      data: '0x00000000000000000000000000000000000000000000000000007b7ba1e9f76f',
      topics: [Array],
      transactionHash: '0xd6baeaba7efe0a3ac68780d0989529f352f5b864792999c88ab9717fb770e35c',
      logIndex: 115,
      removeListener: [Function (anonymous)],
      getBlock: [Function (anonymous)],
      getTransaction: [Function (anonymous)],
      getTransactionReceipt: [Function (anonymous)],
      event: 'Transfer',
      eventSignature: 'Transfer(address,address,uint256)',
      decode: [Function (anonymous)],
      args: [Array]
    }

and then some that are missing the event and args fields:

{
      blockNumber: 10789343,
      blockHash: '0x289150bd3ede2232d22c7942cc08536ccfc0a946d07363f57450ca46418dcdc0',
      transactionIndex: 161,
      removed: false,
      address: '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643',
      data: '0x0000000000000000000000000000000000000000008774d0e485a3ec063a456c000000000000000000000000000000000000000000000006758649801e7630120000000000000000000000000000000000000000000000000e660927316e4048000000000000000000000000000000000000000001e23cbabd51e00c615e49c4',
      topics: [Array],
      transactionHash: '0x8d309caf871307c45ac0e54ee79b04d8538a7ebd90b833faf320c8aa9a2e217c',
      logIndex: 150,
      removeListener: [Function (anonymous)],
      getBlock: [Function (anonymous)],
      getTransaction: [Function (anonymous)],
      getTransactionReceipt: [Function (anonymous)]
    }

what is the reason for both appearing in the result set? Can these events safely be skipped?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
shanecarey17commented, Sep 12, 2020

I was able to solve this with your tip, thanks

0reactions
GodCrypto0616commented, Dec 9, 2022

I tried to get events for “TransferSingle” event, but I can not get them , and it is not returning any value. const _events = await contract.queryFilter(“TransferSingle”, collection.fetchedLastBlockNumber);

Read more comments on GitHub >

github_iconTop Results From Across the Web

[question] why do some events from contract.queryfilter not ...
Hi, when using Contract.queryFilter like this: let eventFilter = [myContract.filters.Transfer()]; let events = await myContract.
Read more >
To get event args when I using ethers.js
I suggest to try OpenZeppelin test helpers. They have a check expectEvent that reads events from the transaction's receipt.
Read more >
ethers-io/Lobby - Gitter
I make a call that trigger lost of events in contract further down the chain, and since the caller contract does not have...
Read more >
EventArgs Constructor (System) - Microsoft Learn
EventArgs Class (System) ... Represents the base class for classes that contain event data, and provides a value to use for events that...
Read more >
Contract event listener is not firing when running hardhat tests ...
The full answer is here: https://github.com/nomiclabs/hardhat/issues/1692#issuecomment-905674692. But to summarise, the reason this doesn't ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found