MetaMask Provider Detection and Connection Flow
in a Production Integration

MetaMask injects a provider object into the browser's JavaScript environment under window.ethereum when the extension is installed. A MetaMask integration begins by detecting this provider and determining whether MetaMask specifically is the injected provider, since other wallet extensions also inject under window.ethereum and may not support all of MetaMask's API methods. Detection logic that does not distinguish between MetaMask and other injected providers can result in errors when the integration attempts to call MetaMask-specific methods on a different wallet's provider.

The connection request flow prompts the user to select an account from their MetaMask wallet and approve the connection to the platform. The integration handles the pending state while the user responds to the MetaMask popup, the approved state when the user confirms the connection, and the rejected state when the user dismisses the popup without connecting. Post-connection, the integration subscribes to MetaMask's account change and network change events so the platform responds correctly when the user switches accounts or networks within MetaMask while connected to the platform. 27 Blockchain builds this complete connection flow management into each MetaMask integration service engagement, so the platform handles all provider states correctly rather than only the happy path.

Back ↵