onOpened

Sets up a listener for the event when a mail is opened by the receiver.

Usage

const receiver = '0x...';

mail.onOpened(receiver, null, (index, openedAt) => {
  console.log(index);
  console.log(openedAt);
});

Stop watching

const stopWatching = mail.onOpened(receiver, null, (index, openedAt) => {
  console.log(index);
  console.log(openedAt);
});

// ... Later, to stop watching for the events
stopWatching();

Returns

UnwatchFn

A function that can be invoked to stop watching for new event logs.

Parameters

receiver

  • Type Address | null

The mail receiver's address. If set to null, it listens for any receiver.

index

  • Type bigint | null

The index of the mail. If set to null, it listens for the opening of any mail.

callback

  • Type (index: bigint, openedAt: bigint) => void

The callback function to be executed when a mail-opened event is detected. It receives the index of the opened mail and its opened timestamp as its arguments.

Previous
onNew