The Wayback Machine - https://web.archive.org/web/20200918184236/https://github.com/trufflesuite/truffle/issues/2962
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for how to filter event logs #2962

Open
wbt opened this issue Apr 15, 2020 · 2 comments
Open

Add documentation for how to filter event logs #2962

wbt opened this issue Apr 15, 2020 · 2 comments

Comments

@wbt
Copy link
Contributor

@wbt wbt commented Apr 15, 2020

Issue

The "Full Example" of using @truffle/contract to interact with contracts should include an example of listening to an event with a filter.

In the past, it used to be possible to pass a filter object on indexed event parameters when listening to an event, as seen for example here (filtering to a particular _candidateName). It is not clear how to do this in the latest version of @truffle/contract, especially since log filter options are no longer passed to web3.eth.filter.

This Issue proposes a documentation change to make this easier to understand.


If you came here looking for a solution, the way to do it is that what used to be the filter object passed in separately now goes in as an object member of the options object, named "filter". So in the linked StackExchange example,

var event = contractInstance.RegisterCandidate( {_candidateName: "Abc"}, {fromBlock: 0, toBlock: 'latest'});

would likely become

var event = contractInstance.RegisterCandidate( {filter: {_candidateName: "Abc"}, fromBlock: 0, toBlock: 'latest'});


Possibly related issue with zero description: #2190

@gnidan
Copy link
Member

@gnidan gnidan commented Apr 15, 2020

Thanks for this @wbt! You're absolutely right that this should be improved in our docs. Feel free to take a stab at it, or we'll get to it as part of our normal (albeit slow) process to work through the backlog.

@wbt
Copy link
Contributor Author

@wbt wbt commented Apr 15, 2020

Having found what should go in there and gotten it documented here, I'll probably be comparably slow towards a PR into the official documentation. Therefore if anyone else reading this wants to jump in, feel free!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.