About the Wallet API
Ethereum provider API
window.ethereum provider object.
This API is specified by EIP-1193, and it allows dapps to
request users' Ethereum accounts, read data from blockchains the user is connected to, suggest
that the user sign messages and transactions, and more.
MetaMask supports EIP-6963, which introduces an
alternative discovery 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 for provider discovery.
The MetaMask Ethereum provider API contains the following:
- Properties - The provider contains a property that detects if a user has MetaMask installed.
- Methods - The provider contains methods that dapps can call.
window.ethereum.request(args)provider method wraps the JSON-RPC API; dapps can use this provider method to call any RPC method.
- Events - The provider emits events that dapps can listen to.
View the provider API reference for all the provider properties, methods, and events.
The RPC methods are documented in the interactive JSON-RPC API reference.
All RPC method requests can return errors.
Make sure to handle errors for every call to
MetaMask introduced wallet permissions in EIP-2255.
In this permissions system, each RPC method is restricted or unrestricted.
If a method is restricted, a dapp must request permission to call it using
Under the hood, permissions are plain, JSON-compatible objects, with fields that are mostly used
internally by MetaMask.
Unrestricted methods do not require requesting permission to call them, but they might still rely on
permissions to succeed (for example, the signing methods require calling the restricted
eth_accounts method), or they might require confirmation by the
user (for example,