---
eip: 7039
label: EIP-7039
title: Scheme-Handler Discovery Option for Wallets
status: Stagnant
type: Standards Track
category: Interface
created: 2023-05-15
requires: 1193
official: https://eips.ethereum.org/EIPS/eip-7039
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7039.md
canonical: https://eips.huatuo.xyz/eip-7039/
lang: en
tldr: "SHADOW: a wallet-discovery idea where a page loads a hidden iframe at web+evm:// and talks EIP-1193 requests over postMessage, letting several wallets coexist without extension permissions."
tags: [wallet, discovery, provider, browser, interface]
---

# EIP-7039: Scheme-Handler Discovery Option for Wallets

> Using custom protocol handlers to initiate connections between web pages and wallets.

**TL;DR:** SHADOW: a wallet-discovery idea where a page loads a hidden iframe at web+evm:// and talks EIP-1193 requests over postMessage, letting several wallets coexist without extension permissions.

## What problem does it solve?

Browser dApps usually find a wallet through `window.ethereum`, an object injected by an extension ([EIP-1193](/eip-1193/)). That has two problems:

- Only **one** wallet can own `window.ethereum` at a time, so multiple installed wallets fight over it.
- To inject it, extensions need broad permissions to run scripts on every page.

EIP-7039, nicknamed **SHADOW** (Scheme-Handler Discovery Option for Wallets), proposes using the browser's custom protocol handlers instead. Any wallet that can serve a web page (an extension, a web wallet, a native app or a hardware wallet companion) registers as the handler for a well-known scheme, and the user picks among them.

## How it works

**Connecting:**

1. The page listens for `"message"` events on `window`.
2. It creates an `<iframe src="web+evm://">` and attaches it to the DOM. The browser loads the registered wallet's handler page inside it.
3. It waits for a message whose `source` is that iframe's `contentWindow`.
4. The first `MessagePort` in that message becomes the **primary port**. The message may carry `{ name, icon }` describing the wallet.

**Talking:**

- Either side can send a request on the primary port. The data follows EIP-1193 `RequestArguments` (`{ method, params }`).
- To get an answer, the requester transfers a fresh **reply port** with the message. The responder posts exactly one `{ result }` or `{ error }` (an EIP-1193 `ProviderRpcError`) on it.
- No reply port means "fire and forget", which is not an error.

Handing over a port instead of using the iframe window directly lets the iframe step aside so page and wallet can talk without proxying.

## Sample code

```ts
function connectShadow(): Promise<MessagePort> {
  return new Promise((resolve) => {
    const iframe = document.createElement("iframe");
    iframe.style.display = "none";
    iframe.src = "web+evm://";

    window.addEventListener("message", function onMsg(ev: MessageEvent) {
      if (!ev.source || ev.source !== iframe.contentWindow) return;
      window.removeEventListener("message", onMsg);
      console.log("wallet:", ev.data?.name);
      resolve(ev.ports[0]); // primary port
    });

    document.body.appendChild(iframe);
  });
}

function request(port: MessagePort, method: string, params?: unknown[]) {
  return new Promise((resolve, reject) => {
    const { port1, port2 } = new MessageChannel();
    port1.onmessage = (ev) => (ev.data.error ? reject(ev.data.error) : resolve(ev.data.result));
    port.postMessage({ method, params }, [port2]); // port2 is the reply port
  });
}

const port = await connectShadow();
const accounts = await request(port, "eth_requestAccounts");
```

## Things to know

- Status is **Stagnant**, and the text is incomplete: the icon format, an EIP-1193 compatibility shim and security considerations are marked TODO.
- Wallet discovery in practice moved to [EIP-6963](/eip-6963/) (Multi Injected Provider Discovery), which solves the "many wallets" problem with window events while still using injected providers.
- Both sides must verify message origins before trusting anything received.
- It relies on the browser's custom protocol handler mechanism (`registerProtocolHandler` for `web+` schemes).


---

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