Skip to main content

JSON-RPC API

MetaMask uses the window.ethereum.request(args) method of the provider API to wrap a JSON-RPC API. The JSON-RPC API contains standard Ethereum JSON-RPC API methods and MetaMask-specific methods.

MetaMask API Playground

The RPC methods are documented in the interactive MetaMask JSON-RPC API Playground.

Methods in the API playground may have the following tags:

  • MetaMask - These methods behave in ways specific to MetaMask, and may or may not be supported by other wallets. Some of these methods are documented in more detail on the JSON-RPC reference.
  • Restricted - These methods are restricted, which require requesting permission using wallet_requestPermissions.
  • Mobile - These methods are only available on MetaMask Mobile.
  • Ethereum API - These are standard Ethereum JSON-RPC API methods. See the Ethereum wiki for more information on these methods.
note

All RPC method requests can return errors. Make sure to handle errors for every call to window.ethereum.request(args).

Restricted methods

MetaMask introduced web3 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 wallet_requestPermissions. Under the hood, permissions are plain, JSON-compatible objects, with fields that are mostly used internally by MetaMask.

Outside of Snaps restricted methods, the only restricted method is eth_accounts, which allows you to access the user's Ethereum accounts. More restricted methods will be added in the future.

Unrestricted methods

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, wallet_addEthereumChain).

See the JSON-RPC API reference for some MetaMask-specific unrestricted methods and examples of how to implement them. For the full list of MetaMask JSON-RPC API methods, see the API playground.