0

After creating a new istance of Dirzzle and passing the needed options:

const drizzle = new Drizzle(options);

The object drizzle.contracts is an empty object instead of being an array of the contracts specified inside the options. Because of that, trying to access the events of a contract by calling:

drizzle.contracts.MyContract.events

Will cause the error:

TypeError: Cannot read property 'events' of undefined

This is because drizzle.contracts.MyContract is undefined. Since, drizzle.contracts is an empty object

0

The new instance of the Drizzle object is not initialized immediatly. And it is done asyncornosly.

We have to wait till it is finished its initialization before being able to access it.

This could be done with the following async code block that has to be called before accesing any contract inside the new drizzle instance.

var state = this.drizzle.store.getState();
while (!state.drizzleStatus.initialized) {
  const delay = new Promise(resolve => setTimeout(resolve, 500));
  await delay;
  state = this.drizzle.store.getState();
  console.log(state.drizzleStatus);
}

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.