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.

Bug: Listening to topic sets doesn't work

See original GitHub issue

I am referring to the documentation provided here My goal is to listen to events on a list of addresses of my choice. I figured the topicset would be useful in this regard.

const topicSet = [
  '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
  null,
  [ '0xf687BfA503376e088C6032cD277EEbdf19af4c7d' ]
]

This is the topic set I tried using, and got this error

p.on(topicSet, (event) => console.log(event))
Uncaught:
Error: invalid topic (argument="topic", value="0xf687BfA503376e088C6032cD277EEbdf19af4c7d", code=INVALID_ARGUMENT, version=providers/5.0.14)
    at Logger.makeError (@ethersproject/logger/lib/index.js:179:21)
    at Logger.throwError (@ethersproject/logger/lib/index.js:188:20)
    at Logger.throwArgumentError (@ethersproject/logger/lib/index.js:191:21)
    at checkTopic (@ethersproject/providers/lib/base-provider.js:75:16)
    at @ethersproject/providers/lib/base-provider.js:90:26
    at Array.forEach (<anonymous>) {
  reason: 'invalid topic',
  code: 'INVALID_ARGUMENT',
  argument: 'topic',
  value: '0xf687BfA503376e088C6032cD277EEbdf19af4c7d'
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Dec 19, 2020

Sorry it’s been so long since I looked into this. Yes, after investigating, I see that the topics were incorrectly encoded. Every topic must be 32 bytes, so the address needs to be zero padded to be 32 bytes wide.

Thanks @andrevmatos! Yes, that is the easiest way to encode any of the static types. To encode any dynamic types, you will need to use utils.id for string and utils.keccak256 for bytes.

I’m guessing that solution worked for you @rymnc?

1reaction
andrevmatoscommented, Dec 2, 2020

I think that, when you’re passing raw topics, you need to encode them first. If you use the interface’s factories for events/topics, then it already encodes it for you. On your case, you’re trying to pass an address (20 bytes long) as topic[2]. Try to encode it with [defaultAbiCoder.encode(['address'], [address])].

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot audio and video issues on your computer or ...
Running the audio troubleshooter may help resolve your issue, but it requires administrative access to your computer. To run troubleshooting ...
Read more >
FM Listening Bug : 12 Steps (with Pictures) - Instructables
1. As you can see in the schematic below this is a very simple circuit and will be an easy build. On thing...
Read more >
[Fixed] No Sound on Windows 10 - Quickly & Easily
If you get no sound error after upgrading to Windows 10 from a previous version of Window. Don't worry. Here are three simple...
Read more >
How to Sweep For Bugs and Hidden Cameras | WIRED
First, take a close look at your surroundings. Carefully check for anything new or out of place, and listen to your gut about...
Read more >
PulseAudio/Troubleshooting - ArchWiki
If sound does not play when PulseAudio's volume is set below a certain level, or if you hear clipping on output even at...
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