1

I am looking to collect the previously logged events of a certain type using getPastEvents. It does not seem to work in my web3 script on my site but it does work in truffle console on a deployed instance. I am using this code:

myContract.getPastEvents('depositTx', {
      fromBlock: 0,
      toBlock: 'latest'
    }, function(error, result) {
      if (!error) {
        console.log(result);
      } else {
        console.log(error);
      }
});

When I create a myContract instance in truffle console it works (e.g. let myContract = await contractName.deployed()) but when I try to run this on my web3 script where I have set the contract using address and ABI it does not (other method calls work fine).

Any thoughts?

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.