# on()

[**EIP-1193 events**](https://eips.ethereum.org/EIPS/eip-1193#events)

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

{% hint style="warning" %}
**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)](https://docs.constellationnetwork.io/stargazer-wallet/chain-provider-api/async-onasync).
{% endhint %}

**Type**

`on(eventName, listener): void`

**Parameters**

| Name      | Type      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| --------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| eventName | `String`  | Event to listen. Depeding on the provider chain one of [Constellation RPC event](https://2892156949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAUvaNviXuvMQPGFFlTu0%2Fuploads%2FlwMsSc6JGh3Hs9uhTPhW%2FconstellationRPCAPI?alt=media) or an [Ethereum RPC event](https://2892156949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAUvaNviXuvMQPGFFlTu0%2Fuploads%2FMUnqupiDBooRpr30wRuc%2FethereumRPCAPI?alt=media). |
| listener  | `()=>any` | Callback function.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

**Return Type**

`void`

**Example**

TypeScript

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