Skip to main content
SparkWallet extends EventEmitter, so it inherits the following methods for handling events.


on(event: string, listener: Function)

Adds a listener for the specified event.
on(event: keyof SparkWalletEvents, listener: Function): this

Parameters

event
string
required
The event name to listen for
listener
Function
required
The callback function to execute when the event is emitted

Returns

this
this
required
The SparkWallet instance for chaining

Example

wallet.on("transfer:claimed", (transferId, updatedBalance) => {
  console.log(`Transfer ${transferId} claimed. New balance: ${updatedBalance}`);
});



once(event: string, listener: Function)

Adds a one-time listener for the specified event.
once(event: keyof SparkWalletEvents, listener: Function): this

Parameters

event
string
required
The event name to listen for
listener
Function
required
The callback function to execute when the event is emitted

Returns

this
this
required
The SparkWallet instance for chaining

Example

wallet.once("transfer:completed", (transferId) => {
  console.log(`Transfer ${transferId} completed!`);
});



off(event: string, listener: Function)

Removes the specified listener from the specified event.
off(event: keyof SparkWalletEvents, listener: Function): this

Parameters

event
string
required
The event name
listener
Function
required
The callback function to remove

Returns

this
this
required
The SparkWallet instance for chaining

Example

const listener = (transferId) => console.log(`Transfer: ${transferId}`);
wallet.on("transfer:claimed", listener);

// Later, remove the listener
wallet.off("transfer:claimed", listener);