1

Calling getPastEvents with Drizzle will cause the exception:

TypeError: this.drizzle.contracts.Contract.getPastEvents is not a function

How to get all the past events in an array (in-one-shot) when working with Drizzle?

0

To access getPastEvents we need to access the original web3 contract instance (ref). This could be achived by using a similar typescript method:

  async getPastEvents(event: string = 'allEvents', options: any) {
    const web3 = this.drizzle.web3;
    const contract = this.drizzle.contracts.Registrar;
    const yourContractWeb3 = new web3.eth.Contract(contract.abi, contract.address);

    return await yourContractWeb3.getPastEvents(event, options);
  }

To call the above method, use someting like:

  const eventOptions = {
    fromBlock: 7228340
    //   toBlock: 'latest'
  };
  const eventsArray = await this.getPastEvents('Registrar', 'BidRevealed', eventOptions);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.