Skip to main content

on()

EIP-1193 events

Registers the listener function as callback of the selected RPC event.

Warning

This method will always return, even if there are errors while adding the listener, for controlling errors generated during the registration process use async onAsync(eventName, listener).

Type

on(eventName, listener): void

Parameters
NameTypeDescription
eventNameStringEvent to listen. Depeding on the provider chain one of Constellation RPC event or an Ethereum RPC event.
listener()=>anyCallback function.
Return Type

void

Example
TypeScript
provider.on("accountsChanged", () => {
// Do something when accounts changed
});