---
eip: 2786
label: EIP-2786
title: Ethereum Provider Connect/Disconnect Events
status: Withdrawn
type: Standards Track
category: Interface
created: 2020-07-15
requires: 2700
official: https://eips.ethereum.org/EIPS/eip-2786
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2786.md
canonical: https://eips.huatuo.xyz/eip-2786/
lang: en
tldr: A withdrawn proposal for injected Ethereum providers to emit `connect` and `disconnect` events when they gain or lose the ability to serve RPC requests; the behavior now lives in EIP-1193.
tags: [provider, javascript, events, wallet, interface]
---

# EIP-2786: Ethereum Provider Connect/Disconnect Events

> When an Ethereum Provider becomes connected or disconnected, it will emit a connect/disconnect event.

**TL;DR:** A withdrawn proposal for injected Ethereum providers to emit `connect` and `disconnect` events when they gain or lose the ability to serve RPC requests; the behavior now lives in EIP-1193.

## What problem does it solve?

A dapp talking to an injected provider (a browser wallet, for example) needs to know when that provider can no longer reach any chain, so it can warn the user instead of failing silently, and when it comes back. Providers already emitted such events in practice, but the behavior was not written down consistently.

EIP-2786 was a mostly retrospective proposal that tried to codify those `connect` / `disconnect` events as a small standalone standard.

## How it works

The proposal defines two states:

- **Connected:** the provider can service RPC requests to at least one chain.
- **Disconnected:** it cannot service RPC requests to any chain.

When the provider goes from disconnected to connected, it must emit `connect` to every listener registered through the [EIP-2700](/eip-2700/) event emitter interface. Listeners receive `{ chainId }`, where `chainId` is the chain's integer ID as a hex string and must match `eth_chainId` if the provider supports it. Listeners may be called in any order.

A matching `disconnect` event is emitted on the opposite transition. Applications decide for themselves whether and how to react.

## Sample code

Listening for both events on an injected provider:

```ts
const provider = (window as any).ethereum;

provider.on("connect", ({ chainId }: { chainId: string }) => {
  console.log("Provider connected to chain", parseInt(chainId, 16));
});

provider.on("disconnect", (error: { code: number; message: string }) => {
  // In EIP-1193 the payload is a ProviderRpcError, typically code 4900
  console.warn("Provider disconnected:", error.code, error.message);
});
```

## Things to know

- Status is **Withdrawn**. Connect and disconnect events are specified in [EIP-1193](/eip-1193/) (Final), which is what wallets and libraries implement. Use that spec, not this one.
- The withdrawn text is internally inconsistent: the abstract swaps the two transitions (it says `connect` fires on going disconnected), and the specification section defines only the `connect` event. The `disconnect` payload in the sample above follows EIP-1193.
- It depends on the [EIP-2700](/eip-2700/) event emitter interface; the request transport is in [EIP-2696](/eip-2696/).
- The rationale notes that per-chain connect/disconnect events were left out to match existing behavior.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-2786
