Skip to content

Handle Provider Events

This guide lists the standard EIP-1193 events that are raised by the AuthProvider in the Arcana Auth SDK and how app developers can handle those events in the app.



AuthProvider emits the following standard EIP-1193 events:

  • connect
  • disconnect
  • chainChanged
  • accountsChanged

After initialization, when the provider is ready to submit the blockchain requests to the chain on behalf of the user, the connect event is generated. Use provider.isConnected() to check if the AuthProvider is connected. Disconnect event occurs when there is any connectivity issue with the network and the provider is not able to submit the blockchain requests. If the chain is switched programmatically via the app and approved by the user or if it is changed via the Arcana wallet UI by the user, the chainChanged event occurs. Similarly, when the account associated with the AuthProvider changes, accountsChanged event is emitted.


Connect Event

interface ConnectEventInfo {
  chainId: string;

const auth = new AuthProvider("...")
await auth.init()


auth.provider.on('connect', handler: (data: ConnectEventInfo) => void);

Disconnect Event

When the AuthProvider becomes disconnected from the chains it emits the event disconnect with the error ProviderRpcError.

interface ProviderRpcError extends Error {
  code: number;
  data?: unknown;

const auth = new AuthProvider("...")
await auth.init()


auth.provider.on('disconnect', handler: (error: ProviderRpcError) => void);

Chain Changed Event

const auth = new AuthProvider("...")
await auth.init()


auth.provider.on('chainChanged', (chainId: string) => { 
  // Use chainId

Accounts Changed Event

If the accounts available to the AuthProvider change, it emits the event accountsChanged with value accounts: string[], containing the account addresses.

const auth = new AuthProvider("...")
await auth.init()


auth.provider.on('accountsChanged', handler: (accounts: Array<string>) => void);

Remove Listener

Make sure that you remove event listeners once you're done listening to an event in the app. For example:

const auth = new AuthProvider("...")
await auth.init()


function handleSomeEvent(accounts) {
  // Handle the event

auth.provider.on('someEvent', handleSomeEvent);

// Later, when the component is unloaded or you are done watching the event

auth.provider.removeListener('someEvent', handleSomeEvent);

That is all!

You are all set to handle the events emitted by the AuthProvider.

What's Next?

Authenticated users can use the Arcana wallet to sign blockchain transactions, send and receive native, ERC20, or custom tokens, and more.

See also

Last update: August 28, 2023 by shaloo