In my solidity contract, I just have one event which is:
transferOwnerShip (uint id, address indexed newowner);
and I want to filter the events log in order to retrieve only the events that belong to specific **newowner address**
I used this JavaScript code
var newlog;
var events = DeviceManagerContractInstance.allEvents(
{fromBlock: 0, toBlock: 'latest'} ,
{newowner:"0xe6b56e8f11f2dd687d63c75cda3f261ae1124054"});
events.get(function(error, log) {
if(!error)
{
console.log(log);
for( var property in log) {
newlog += "Event " + property + ': '+'\n' + JSON.stringify(log[property],null,4)+'\r\n';
document.getElementById("eventID").innerHTML = newlog;
}
}
});
where DeviceManagerContractInstance is my contract instance
but I received all the events for all addresses. So, What is the best way to retrieve event based on specific data args?
Besides, Is there any way to print specific data from the event instead of the whole object.
- Truffle v5.0.27 (core: 5.0.27)
- Solidity v0.5.0 (solc-js)
- Node v10.15.3
- Web3.js v1.0.0-beta.37
- geth Version: 1.9.6-stable