0

I'm trying to filter some events , and I noticed since I updated the web3 to version 2.0.0-alpha 1 the event catch is a little bit different.

I have a Smart Contract with this event :

event catchMeIfYouCan (address indexed a, string indexed b, uint indexed c);

And I want to filter by its parameters , so far so good. But when I try to filter by b ( the string indexed ) , this is not working. I'm doing that in NodeJS with ExpressJS and the Web3 version mentioned above.

If I do that :

const event = smartContract.events.catchMeIfYouCan({ filter : {
 a : accountAddress ,
 b : web3.utils.toHex(stringValue) ,
 c : web3.utils.toWei("" + numberValue) } 
}, (error, event) => {
 // do some things
});

I get :

Node error: {"code":-32602,"message":"invalid argument 1: hex has invalid length 96 after decoding"}

Otherwise , if I let the b parameter , in NodeJS event catch as :

 b : stringValue,

It doesn't catch the event anymore , same with c ( e.g : no more web3.utils.toWei() ).

So , my question is : Do you have any idea how to filter the event by a string parameter in Web3 2.0.0-Alpha 1 version ?

Thank you for help & Have a nice day!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.