2

Using web.js, I can query the event logs of a contract using the "web3.eth.filter" method. The documentation states that this method accepts an object with a "topics" property, which is says are "An array of values which must each appear in the log entries".

My question, can I match a substring of a topic? For example, say I have an event like this:

event AddedEntity (
    string indexed _title
    string indexed _contents,
    uint256 indexed _id
);

and I fire that event in the smart contract like so:

AddedEntity("Week 34", "Interesting Data", 142);

Can I search the contract's event logs for the keyword "Interesting" and expect a match? Or will I only find a match if I search for "Interesting Data"?

3

For indexed arguments, only the hash of the value is used, so no it is not possible to search for a substring, only exact values will match.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.