JSON-RPC API
MetaMask uses the window.ethereum.request(args) provider method to wrap a JSON-RPC API. The 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 this page.
- Restricted — These methods are restricted, which require requesting permission using wallet_requestPermissions .
- Mobile — These methods are only available on MetaMask Mobile.
For more information on the standard Ethereum RPC methods, see the Ethereum wiki.
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_requestPermssions . 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 have no corresponding permission, 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 ).
The following are some MetaMask-specific unrestricted methods. For the full list of MetaMask JSON-RPC API methods, see the API playground.
eth_requestAccounts
Requests that the user provide an Ethereum address to be identified by. Use this method to access a user’s accounts.
This method is specified by EIP-1102.
Internally, this method calls wallet_requestPermissions for permission to call eth_accounts .
Returns
If the user accepts the request, this method returns an array of a single, hexadecimal Ethereum address string. If they reject the request, this method rejects with a 4001 error.
Example
document.getElementById('connectButton', connect); function connect() ethereum .request( method: 'eth_requestAccounts' >) .then(handleAccountsChanged) .catch((error) => if (error.code === 4001) // EIP-1193 userRejectedRequest error console.log('Please connect to MetaMask.'); > else console.error(error); > >); >
wallet_getPermissions
Gets the caller’s current permissions.
This method is not yet available on MetaMask Mobile.
Returns
An array of the caller’s permission objects. If the caller has no permissions, the array is empty.
wallet_requestPermissions
Requests permissions from the user.
The request causes a MetaMask popup to appear. You should only request permissions in response to a direct user action, such as a button click.
This method is not yet available on MetaMask Mobile.
Parameters
An array containing the requested permission objects.
Returns
An array of the caller’s permission objects. If the user denies the request, a 4001 error is returned.
Example
document.getElementById('requestPermissionsButton', requestPermissions); function requestPermissions() ethereum .request( method: 'wallet_requestPermissions', params: [ eth_accounts: > >], >) .then((permissions) => const accountsPermission = permissions.find( (permission) => permission.parentCapability === 'eth_accounts' ); if (accountsPermission) console.log('eth_accounts permission successfully requested!'); > >) .catch((error) => if (error.code === 4001) // EIP-1193 userRejectedRequest error console.log('Permissions needed to continue.'); > else console.error(error); > >); >
wallet_addEthereumChain
Creates a confirmation asking the user to add the specified chain to MetaMask. The user may choose to switch to the chain once it has been added.
You should only call this method in response to a direct user action, such as a button click.
MetaMask validates the parameters for this method, and rejects the request if any parameter is incorrectly formatted. MetaMask also rejects the request if any of the following occurs:
-
The RPC endpoint doesn’t respond to RPC calls.
Calls are made from the extension’s background page, not the foreground page. If you use an origin allowlist, they’re blocked.
This method is specified by EIP-3085.
Parameters
An array containing an object containing the following metadata about the chain to be added to MetaMask:
- chainId — The chain ID as a 0x -prefixed hexadecimal string.
- chainName — The name of the chain.
- nativeCurrency — An object containing:
- name — The name of the currency.
- symbol — The symbol of the currency, as a 2-6 character string.
- decimals — The number of decimals of the currency. Currently only accepts 18 .
Returns
null if the request was successful, and an error otherwise.
Example
We recommend using this method with wallet_addEthereumChain :
try await ethereum.request( method: 'wallet_switchEthereumChain', params: [ chainId: '0xf00' >], >); > catch (switchError) // This error code indicates that the chain has not been added to MetaMask. if (switchError.code === 4902) try await ethereum.request( method: 'wallet_addEthereumChain', params: [ chainId: '0xf00', chainName: '. ', rpcUrls: ['https://. '] /* . */, >, ], >); > catch (addError) // handle "add" error > > // handle other "switch" errors >wallet_switchEthereumChain
Creates a confirmation asking the user to switch to the chain with the specified chain ID.
You should only call this method in response to a direct user action, such as a button click.
MetaMask rejects the request if any of the following occurs:
- The chain ID is malformed.
- The chain with the specified chain ID hasn’t been added to MetaMask.
This method is specified by EIP-3326.
Parameters
An array containing an object containing chainId , the chain ID as a 0x -prefixed hexadecimal string.
Returns
null if the request was successful, and an error otherwise.
If the error code is 4902 , the requested chain hasn’t been added by MetaMask, and you must request to add it using wallet_addEthereumChain .
Example
wallet_registerOnboarding
Registers the requesting site with MetaMask as the initiator of onboarding, enabling MetaMask to redirect the user back to the site after onboarding has completed.
This method is intended to be called after MetaMask has been installed, but before the MetaMask onboarding has completed.
Instead of calling this method directly, you should use the MetaMask onboarding library.
Returns
true if the request was successful, false otherwise.
wallet_watchAsset
Requests that the user track the specified token in MetaMask.
Most Ethereum wallets support some set of tokens, usually from a centrally curated registry of tokens. This method enables dapp developers to ask their users to track tokens in their wallets, at runtime. Once added, the token is indistinguishable from those added using legacy methods, such as a centralized registry.
This method is specified by EIP-747.
Parameters
An object containing the following metadata of the token to watch:
- type — Currently only supports ERC20 .
- options — An object containing:
- address — The address of the token contract.
- symbol — The symbol of the token, up to 11 characters.
- decimals — The number of token decimals.
- image — A URL string of the token logo.
Returns
true if the token was added, false otherwise.
Example
ethereum .request( method: 'wallet_watchAsset', params: type: 'ERC20', options: address: '0xb60e8dd61c5d32be8058bb8eb970870f07233155', symbol: 'FOO', decimals: 18, image: 'https://foo.io/token-image.svg', >, >, >) .then((success) => if (success) console.log('FOO successfully added to wallet!'); > else throw new Error('Something went wrong.'); > >) .catch(console.error);wallet_scanQRCode
Requests that the user scan a QR code using their device camera.
MetaMask previously introduced this feature in EIP-945. The functionality was temporarily removed before being re-introduced as this RPC method.
This method is only available on MetaMask Mobile.
Parameters
An array containing an optional regular expression (regex) string for matching arbitrary QR code strings.
Returns
A string corresponding to the scanned QR code. If a regex string is provided, the resulting string matches it. If no regex string is provided, the resulting string matches an Ethereum address. If neither condition is met, the method returns an error.
Example
ethereum .request( method: 'wallet_scanQRCode', // The regex string must be valid input to the RegExp constructor, if provided params: ['\\D'], >) .then((result) => console.log(result); >) .catch((error) => console.log(error); >);- Restricted methods
- Unrestricted methods
- eth_requestAccounts
- wallet_getPermissions
- wallet_requestPermissions
- wallet_addEthereumChain
- wallet_switchEthereumChain
- wallet_registerOnboarding
- wallet_watchAsset
- wallet_scanQRCode
Как сменить поставщика узлов в Метамаск
Смена поставщика узлов может быть полезна в самых разных ситуациях, начиная с медленной работы Infura и заканчивая различными санкционными блокировками.
Автор: Владимир Кузнецов
Последнее обновление: 26.01.2023
Из этой статьи вы узнаете как заменить поставщика узлов Infura в кошельке Metamask и установить альтернативу в виде Alchemy. Смена поставщика может быть полезна в разных ситуациях, самыми распространенными являются: медленная работа Infura и различные санкционные блокировки. Alchemy интегрируется в Метамаск в два простых шага. Помните, что Alchemy не будет иметь доступ к вашим закрытым ключам или кошельку!
Шаг 1. Создаем бесплатную учетную запись на сайте www.alchemy.com
Учетная запись будет необходима для создания ключа Alchemy API, который будет использоваться при замене узла в кошельке Метамаск.
Шаг 2. Создаем API ключ для основной сети Ethereum в Alchemy. В панели управления нажимаем на кнопку +Create App и заполняем следующие данные:
- Name — Указываем название
- Description — Указываем описание
- Chain — Выбираем блокчейн
- Network — Выбираем рабочую сеть
Название и описание можете указать любое. Эти данные используются для вашего собственного удобства. А вот к выбору блокчейна и рабочей сети стоит подойти более внимательно. Выбираем тот блокчейн, поставщика узлов в котором нам необходимо заменить. В своем примере я буду менять поставщика для Ethereum. Но вы должны также знать, что помимо Ethereum, Alchemy поддерживает работу с Polygon, Solana, Arbitrum, Optimism и Astar. Рабочую сеть устанавливаем Mainnet. Жмем Create App:

После создания приложения, чтобы получить необходимые данные для переключения поставщика узлов необходимо нажать на кнопку View Key. Во всплывающем окне вы увидите все, что нам будет необходимо:

Шаг 3. Прописываем полученные данные в настройки Метамаск. Открываем кошелек Метамаск и кликаем по названию сети к которой подключены. Выбираем пункт Add Network —> Add a network manually. Заполняем следующие данные:
- Network name — Название рабочей сети. Название можно взять любое, главное чтобы не запутаться самому. Я указал: Alchemy — Ethereum Mainnet.
- New RPC URL — Ссылка на новый RPC. Берем из всплывающего окна на предыдущем шаге.
- Chain ID — Идентификатор цепочки блоков:
- Ethereum — 1
- Ropsten Test Network — 3
- Rinkeby Test Network — 4
- Goerli Test Network — 5
- Kovan Test Network — 42
- Polygon (Matic) Mainnet — 137
- Polygon (Matic) Mumbai — 80001
- Arbitrum (Mainnet) — 42161
- Arbitrum (Testnet) — 421613
- Optimism (Mainnet) — 10
- Optimism (Testnet) — 420
Заполнив все данные жмем Save:

На этом все. Теперь Метамаск будет использовать Alchemy для подключения к блокчейну Ethereum. Если вы хотите подключить другие блокчейны, то повторите вышеописанные действия, меняя лишь те настройки, что относятся к определенному блокчейну.
How to Change RPC in Metamask A Step by Step Guide

Metamask is a popular browser extension that allows users to interact with decentralized applications (dApps) on the Ethereum blockchain. By default, Metamask connects to the Ethereum mainnet using the default RPC (Remote Procedure Call) endpoint. However, there are instances when you may want to switch to a different RPC endpoint, such as when testing a dApp on a testnet or connecting to a private network.
This step-by-step guide will walk you through the process of changing the RPC in Metamask to connect to a different network. It assumes that you already have Metamask installed and set up.
Step 1: Open the Metamask extension by clicking on the Metamask icon in your browser’s toolbar. If you have not logged in, enter your password or seed phrase to unlock your account.
Step 2: Once you are logged in, you will see your account details in the top right corner of the Metamask window. Click on the network name, which is usually set to “Main Ethereum Network” by default.
Step 3: A drop-down menu will appear with a list of supported networks. Select the network you want to switch to, such as “Rinkeby Test Network” or “Custom RPC.”
Step 4: After selecting the network, Metamask will prompt you to confirm the switch. Take note that switching networks will disconnect you from any dApps you may be currently using. Click on the “Switch” button to proceed.
Step 5: Once the switch is confirmed, Metamask will connect to the new RPC endpoint. You can verify the change by checking the network name in the top right corner of the Metamask window. You are now ready to interact with dApps on the new network!
Changing the RPC in Metamask is a simple process that allows you to connect to different networks based on your needs. Whether you are testing a dApp on a testnet or exploring a private network, Metamask provides the flexibility to easily switch between different RPC endpoints. Follow this step-by-step guide and start exploring the decentralized world of Ethereum!
What is Metamask?

Metamask is a cryptocurrency wallet and browser extension that allows users to interact with decentralized applications (DApps) on the Ethereum blockchain. It acts as a bridge between web browsers and blockchain networks, enabling users to securely manage their cryptocurrency assets and seamlessly connect to various DApps.
With Metamask, users can create and manage multiple Ethereum accounts, store and transfer various cryptocurrencies, and easily access Ethereum-based DApps without the need for installing separate software or browser extensions. It provides a user-friendly and intuitive interface for interacting with the blockchain, making it convenient for both new and experienced cryptocurrency users.
Metamask also serves as a key component for developers and DApp creators, as it provides a simple and standardized way for their applications to connect with users’ wallets and securely perform blockchain transactions. It offers a variety of developer tools and APIs, making it easier to integrate decentralized features into web applications.
Overall, Metamask is a powerful tool that brings together the worlds of web browsing and blockchain technology, enabling users to securely manage their digital assets and seamlessly interact with decentralized applications on the Ethereum blockchain.
What is RPC in Metamask?

RPC stands for Remote Procedure Call, which is a communication protocol used by Metamask to interact with the Ethereum blockchain. It allows Metamask to send requests to the blockchain network and receive responses to perform various actions like querying account balances, signing transactions, and deploying smart contracts.
By changing the RPC in Metamask, users can connect to different Ethereum networks or private local networks. It enables users to switch between mainnet, testnets, or even custom networks to access different decentralized applications (DApps).
RPC acts as a bridge between Metamask and the Ethereum blockchain, enabling smooth and secure transactions by translating requests from the user interface to the blockchain network. It provides an interface for users to interact with Ethereum-based applications without the need to run a full node.
Metamask supports various RPC networks, including the Ethereum Main Network, Ropsten, Kovan, Rinkeby, and local private networks. Each network has its own RPC URL, which users can configure in Metamask settings to connect to their desired network.
Changing the RPC in Metamask is necessary when users want to interact with specific networks other than the default network. It allows users to explore different blockchain ecosystems, test smart contracts, and participate in various decentralized applications based on different networks.
Overall, RPC is an essential component of Metamask that enables users to securely interact with the Ethereum blockchain and access various decentralized applications on different networks.
What is RPC in Metamask?
RPC stands for “Remote Procedure Call” and in the context of Metamask, it refers to the endpoint or URL that allows you to connect to a specific blockchain network. By changing the RPC in Metamask, you can connect to different networks like the Ethereum mainnet, testnets, or even private networks.
Are there any risks involved in changing the RPC in Metamask?
While changing the RPC in Metamask is generally safe, it’s important to be cautious and verify the RPC URL before connecting to it. Using a malicious RPC can potentially put your funds and personal information at risk. Always make sure to double-check the source of the RPC URL and ensure it’s from a trusted and reputable source.
How to Add a Custom RPC to Metamask Wallet
A STEP BY STEP METHOD ON HOW TO ADD YOUR CUSTOM RPC NETWORK TO METAMASK.
By CryptoWallet
Related Post
Setting Up and Utilizing an ERC20 Wallet Using Metamask
Jan 22, 2024 CryptoWallet
How to Transfer Funds from Coinbase to MetaMask
Jan 22, 2024 CryptoWallet
How to Add a Network to Metamask: A Step-by-Step Guide
Jan 22, 2024 CryptoWallet
Leave a Reply Cancel reply

Here are some key features and functions of MetaMask:
- Wallet Management:
- MetaMask provides users with a secure and user-friendly Ethereum wallet.
- It allows users to create and manage multiple Ethereum accounts within the wallet.
- Browser Extension:
- MetaMask is primarily a browser extension, compatible with popular browsers like Chrome, Firefox, and Brave.
- This extension injects a JavaScript library into web pages, enabling seamless interaction with Ethereum-based content.
- Interaction with DApps:
- MetaMask enables users to interact with decentralized applications (DApps) directly from their web browser. This includes accessing DeFi platforms, decentralized exchanges, and various other Ethereum-based applications.
- Token Management:
- Users can manage various Ethereum-based tokens within the MetaMask wallet.
- It supports both Ethereum’s native currency (Ether) and ERC-20 tokens.
- DeFi Integration:
- MetaMask is widely used for participating in decentralized finance (DeFi) protocols. Users can lend, borrow, trade, and stake their crypto assets through supported DeFi platforms.
- NFT Support:
- MetaMask facilitates the creation, purchase, and management of non-fungible tokens (NFTs). NFTs are unique digital assets that represent ownership of specific items or content on the blockchain.
- Security and Privacy:
- MetaMask prioritizes security and provides users with control over their private keys.
- Users are encouraged to store their seed phrases securely, as they are crucial for wallet recovery.
- Network Switching:
- Users can switch between different Ethereum networks, such as the Ethereum mainnet, testnets, and custom networks.
- Open Source:
- MetaMask is an open-source project, allowing developers to contribute to its development and audit the code for security.
MetaMask has played a significant role in facilitating user adoption of decentralized technologies and has become an integral tool for those navigating the Ethereum ecosystem. It continues to evolve with ongoing updates and improvements to meet the growing demands of the crypto space.

Certainly! Continuing from the previous information:
Cross-Platform Compatibility:
In addition to browser extensions, MetaMask has expanded its compatibility to include mobile applications. Users can now access their MetaMask wallet and interact with DApps on both desktop and mobile devices.
Ethereum Name Service (ENS) Integration:
MetaMask integrates with the Ethereum Name Service, allowing users to associate human-readable names with their Ethereum addresses. This simplifies the process of sending and receiving transactions.
Custom RPC Support:
Advanced users and developers can configure MetaMask to connect to custom Ethereum networks by adding custom RPC (Remote Procedure Call) endpoints. This is particularly useful for testing and development purposes.
Educational Resources:
MetaMask provides educational resources through its website, blog, and social media channels. This includes tutorials, guides, and articles to help users understand blockchain technology and how to use MetaMask effectively.
Community and Ecosystem:
MetaMask has a vibrant and active community that contributes to its development and supports users through forums and social media. The ecosystem around MetaMask continues to grow, with new DApps and projects integrating with the wallet.
Security Best Practices:
MetaMask emphasizes the importance of security best practices. Users are encouraged to verify the authenticity of websites before interacting with them, and MetaMask displays warnings for potential phishing attempts.
Privacy Features:
MetaMask aims to provide users with privacy features, and it does not track users’ transaction history or store any personal information. Users have control over their data and can clear their transaction history if desired.
Updates and Improvements:
The MetaMask team regularly releases updates to improve security, performance, and user experience. Users are encouraged to keep their MetaMask extension or app up to date to benefit from the latest features and enhancements.
It’s important to note that while MetaMask is widely used on the Ethereum blockchain, it has also expanded support for other blockchains through the «Custom RPC» feature, allowing users to interact with DApps on different networks. However, Ethereum remains its primary focus.How to switch Metamask RPC to Polygon | How to change RPC in Polygon

In this article, I will show you How to switch Metamask RPC to Matic network. Over the last few months, many of us is facing a common problem in Opensea while uploading NFTs via the Polygon network. When we are trying to List our NFT on Opensea it shows “Please Switch your wallet’s RPC to the Matic network“.
Follow the steps below and fix your problem very easily:
For Desktop:
- First, open your Metamask wallet.
- Click on the Access Account Details (Profile Picture).
- Go to the bottom there you will find Settings.
- After clicking on the settings. Click on the Network option. And select the Polygon network (or Matic Mainnet, or Matic — the naming can differ) from the list:
- If there is no Polygon option. Then create a new one.
- Now enter the following details:

Using https://polygon-rpc.com is most recommended as it aggregates multiple RPC URLs! See below for more information.
7. And finally click on the Save button.