I have my sample contract as:-
pragma solidity ^0.4.24;
contract Storage {
uint256 storedData;
event print(uint256 store);
function set(uint256 data) public {
emit print(data);
storedData = data;
}
function get() constant returns (uint256) {
return storedData;
}
}
After setting the value from geth console and mining it, when I use get function to check the value it returns the correct value which was set earlier. However when I try to get the event logs with the following code:-
var eve = instance.print({sender:eth.coinbase},{fromBlock: 0, toBlock: "latest"});
var allValues = eve.get();allValues[allValues.length - 1].args;
console.log(allValues[allValues.length - 1].args.store);
Here instance is the contract instance, It shows the error as cannot access member args of undefined.
set
function.set
).{sender: eth.coinbase}
. I'm not sure what that's supposed to be doing or if it's having any harmful effect, but I would try removing it. (Just use{}
instead as the first parameter, since you don't want to filter at all.)