EIP-6963 · Final · Interface · 2023-05-01
EIP-6963: Multi Injected Provider Discovery
Lets every installed browser wallet announce itself to a dapp through window events, so users can pick their wallet instead of whichever extension won the race for window.ethereum.
What problem does it solve?
Browser wallet extensions expose their EIP-1193 provider on one shared global, window.ethereum. Extensions load in unpredictable order, so with several wallets installed the last one to load usually wins, and some wallets deliberately delay injection to overwrite the others. Users can't reliably choose a wallet, and new wallets struggle because users effectively have to uninstall the incumbent.
EIP-6963 replaces the shared variable with an event-based handshake. Each wallet announces itself, the dapp collects all announcements, and the user chooses from a list.
How it works
Two window events form the protocol:
eip6963:announceProvider, aCustomEventsent by a wallet. Itsdetailis a frozen{ info, provider }object.eip6963:requestProvider, a plainEventsent by the dapp, asking wallets to (re)announce.
A wallet must dispatch an announce event when it loads and listen for request events, answering each with another announce. A dapp must add its announce listener first, keep it for the page's lifetime, and then dispatch a request. Whichever side loads first, the dapp ends up with every wallet.
info (EIP6963ProviderInfo) contains:
| Field | Meaning |
|---|---|
uuid |
UUIDv4 for this provider session, to tell announcements apart |
name |
Human-readable wallet name |
icon |
Data URI image (RFC 2397), at least 96×96px, square |
rdns |
Reverse-DNS identifier, e.g. com.example.wallet, stable across sessions |
Wallets should keep injecting window.ethereum for older dapps. Dapps should use 6963 discovery and fall back to window.ethereum only if no wallet announces.
Sample code
Dapp-side discovery with ethers v6:
import { BrowserProvider } from "ethers";
type Detail = { info: { uuid: string; name: string; icon: string; rdns: string }; provider: any };
const wallets = new Map<string, Detail>();
window.addEventListener("eip6963:announceProvider", (e: Event) => {
const { detail } = e as CustomEvent<Detail>;
wallets.set(detail.info.uuid, detail);
render();
});
window.dispatchEvent(new Event("eip6963:requestProvider"));
function render() {
const list = document.getElementById("wallets")!;
list.replaceChildren();
for (const { info, provider } of wallets.values()) {
const img = document.createElement("img"); // icons only via <img>
img.src = info.icon;
img.alt = info.name;
img.onclick = async () => {
const signer = await new BrowserProvider(provider).getSigner();
console.log(info.rdns, await signer.getAddress());
};
list.append(img);
}
}
Wallet side, in short:
const announce = () =>
window.dispatchEvent(new CustomEvent("eip6963:announceProvider", {
detail: Object.freeze({ info, provider }),
}));
window.addEventListener("eip6963:requestProvider", announce);
announce();
Things to know
- Status: Final. It succeeded the earlier ERC-5749
window.evmprovidersidea, and wallet connection libraries widely support it. - Render icons only through
<img>. SVG can contain scripts that would run in the page. rdnsandnameare self-reported and can be spoofed. Don't use them for feature detection or trust decisions without extra verification. Two announcements with the sameuuidsuggest tampering.- Wallets should
Object.freezethe announced detail to stop other scripts from modifying it. - Because the dapp asks first, a wallet can wait for a request and ask the user's consent before revealing itself, which reduces fingerprinting.