My Dapp needs to dynamically deploy contracts. As such, I need to store the addresses of these contracts somewhere and opted for the following solution:
- Log creation event
- Retrieve contracts based on logs
The snippet which performs logging is this one:
event Created(address indexed _who, address indexed _to_whom, uint money, uint _max_duration);
//...
Created(msg.sender, _to_address, money_quantity, _contract_max_duration);
In web3.js I'm having a hard time trying to understand how to filter logs based on: Contract Type, _who parameter and eventually _to_whom parameter.
I'm getting all the logs (in js):
var filter = web3.eth.filter({fromBlock:0, toBlock: 'latest', topics: [/* ????!!! */]});
filter.get(function(error, result) {
console.log(result)
})
In the console I get the hashes of 3 "topics" which I suggest, by reverse engineering, are the Contract Type hash and the other two indexed event parameters.
Let's say that I want to query for all events of type Contract Type having the current user as _who parameter. How do I do it? What do I insert in the topics
argument?
Many thanks