Ethereum provider API
This page is a reference for the Ethereum provider API of MetaMask's Wallet API.
MetaMask injects the provider API into websites visited by its users using the window.ethereum
provider object.
You can use the provider properties, methods, and events in your dapp.
MetaMask supports EIP-6963, which introduces an
alternative wallet detection mechanism to the window.ethereum
injected provider.
This alternative mechanism enables dapps to support wallet interoperability
by discovering multiple injected wallet providers in a user's browser.
We recommend using this mechanism to connect to MetaMask.
You can access the provider API using the selected EIP-6963 provider object.
Throughout this documentation, we refer to the selected provider using provider
.
Properties
isMetaMask
This property is true
if the user has MetaMask installed, and false
otherwise.
This property is non-standard.
Non-MetaMask providers may also set this property to true
.
Example
provider.isMetaMask // Or window.ethereum.isMetaMask if you don't support EIP-6963.
Methods
isConnected()
Indicates whether the provider is connected to the current chain.
If the provider isn't connected, the page must be reloaded to re-establish the connection.
See the connect
and disconnect
events for more information.
This method is unrelated to accessing a user's accounts. In the provider interface, "connected" and "disconnected" refer to whether the provider can make RPC requests to the current chain.
Parameters
None.
Returns
true
if the provider is connected to the current chain, false
otherwise.
Example
provider.isConnected() // Or window.ethereum.isConnected() if you don't support EIP-6963.