Published on

Drizzle Contract On Events

Authors

In a previous post I went through how to deal with errors and successes when using drizzle to call a contract. One thing that has stumped me with drizzle is how do you get the response from a contract method that mutates state but returns a value?

While I did not find the exact answer I did find a workaround where I get the event fired by that method and get the data from that method. Drizzle contracts have the receipt .on which can be used to get the transaction receipt which has the associated events in.

Based on here it looks like Drizzle contracts have the following ons and associated callbacks for transactions:

.on stringcallback
transactionHash(transactionHash) =>
confirmation(confirmationNumber, receipt) => {
receipt(receipt) => {
error(error, receipt) => {

And for events:

.on stringcallback
data(event) => {
changed(event) => {
error(error) => {