Class: Events

Events(options)

Service class for listening to on-chain events from the subscriptions, subscription plans and vault contracts.

Constructor

new Events(options)

Create an instance of the Events service.
Parameters:
Name Type Description
options See CaskSDK configuration.
See:

Methods

(async) init(args)

Initialize the event notification service.
Parameters:
Name Type Description
args Object Function arguments
Properties
Name Type Attributes Description
ethersConnection EthersConnection <optional>
EthersConnection instance

(async) listen(args)

Start listening for Cask contract events.
Parameters:
Name Type Description
args Object Function arguments
Properties
Name Type Attributes Default Description
fromBlock string | number <optional>
latest Listen for events starting at this block
subscriptionEvents Array.<string> <optional>
List of subscription event names to listen for. Defaults to all subscription events.
subscriptionFilter Object <optional>
Filter for subscription events
vaultAssetEvents Array.<string> <optional>
List of vault event names to listen for. Defaults to all vault asset events.
vaultAssetFilter Object <optional>
Filter for subscription events
vaultPaymentEvents Array.<string> <optional>
List of vault payment event names to listen for. Defaults to all vault payment events.
vaultPaymentFilter Object <optional>
Filter for subscription events
subscriptionPlanEvents Array.<string> <optional>
List of subscription plans event names to listen for. Defaults to all subscription plans events.
subscriptionPlanFilter Object <optional>
Filter for subscription events

registerHandler(eventName, handler)

Register a callback to be called for a specified event.
Parameters:
Name Type Description
eventName Event name to listen for, or specify 'ALL' for callback to receive all event types.
handler Callback handler

removeHandlers(eventName)

Unregister handlers for a specific event name.
Parameters:
Name Type Description
eventName Event name to unregister, or specify 'ALL' to unregister a wildcard callback.

stop()

Stop listening for events.