2

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 agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.