EIP-6963 Multi-Injected Provider Discovery Utilities

0.0.7 · active · verified Sun Apr 19

mipd (Multi Injected Provider Discovery) is a TypeScript utility library from the wevm (formerly wagmi-dev) ecosystem, designed to facilitate the discovery and management of EIP-6963 compliant Ethereum wallet providers within dapps. EIP-6963 standardizes how multiple injected wallets announce themselves via custom DOM events, moving beyond the single `window.ethereum` paradigm. Currently at version 0.0.7, mipd offers a reactive store (`createStore`) that accumulates announced `EIP6963ProviderDetail` objects and allows dapps to subscribe to updates or retrieve the current list of providers. It includes essential TypeScript types such as `EIP6963ProviderDetail` and `EIP6963AnnounceProviderEvent`, and also provides a `/window` polyfill for enhanced type inference on global event listeners. Its release cadence is likely tied to updates within the broader wevm stack and EIP-6963 evolution. mipd is a foundational component for building robust multi-wallet dapps, complementing libraries like wagmi and viem by abstracting EIP-6963 complexities.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize the EIP-6963 store, subscribe to provider announcements, retrieve current providers, and includes a conceptual React example using `useSyncExternalStore`.

import { createStore } from 'mipd';
import type { EIP6963ProviderDetail } from 'mipd';
import 'mipd/window'; // Import to augment window types for EIP-6963 events

// Create a new EIP-6963 provider store
const mipdStore = createStore();

// Subscribe to provider changes (e.g., when a wallet announces itself or is removed)
const unsubscribe = mipdStore.subscribe((providers: EIP6963ProviderDetail[]) => {
  console.log('EIP-6963 Providers updated:', providers);
  if (providers.length > 0) {
    console.log('First provider UUID:', providers[0].info.uuid);
    console.log('First provider Name:', providers[0].info.name);
    // You can now use providers[0].provider for interactions if needed
  }
});

// Get current providers immediately
const initialProviders = mipdStore.getProviders();
console.log('Initial EIP-6963 Providers:', initialProviders);

// Example of how you might stop listening after some time (in a real app, this would be on unmount)
setTimeout(() => {
  unsubscribe();
  console.log('Unsubscribed from mipd store updates.');
}, 10000);

// In a React component (using React 18+ useSyncExternalStore):
// import { useSyncExternalStore } from 'react';
// import { createStore } from 'mipd';

// const store = createStore();

// function MyWalletConnector() {
//   const providers = useSyncExternalStore(store.subscribe, store.getProviders);
//   return (
//     <div>
//       <h2>Detected EIP-6963 Wallets:</h2>
//       {providers.length === 0 ? (
//         <p>No EIP-6963 wallets found.</p>
//       ) : (
//         <ul>
//           {providers.map((providerDetail) => (
//             <li key={providerDetail.info.uuid}>
//               <img src={providerDetail.info.icon} alt={providerDetail.info.name} width="24" height="24" />
//               {providerDetail.info.name} ({providerDetail.info.rdns})
//             </li>
//           ))}
//         </ul>
//       )}
//     </div>
//   );
// }

view raw JSON →