Jump to content
Onchain Report

Crypto news from every chain

MetaMask users: replace a shared RPC with your own key

How do I add my own RPC URL with an API key to MetaMask? Add your provider’s chain-specific HTTPS endpoint, make it the default and check provider activity.

Onchain Report Newsroom#29e5e93 min read

MetaMask users: replace a shared RPC with your own key

To put your own provider RPC URL with an API key into MetaMask, add the chain-specific HTTPS endpoint to the existing network, select it as default and save. Start with the network already in MetaMask on a public RPC; your provider dashboard should show requests from your wallet when the switch works.

Add the provider URL to your MetaMask network

MetaMask can store several RPC URLs for one network and send requests through the one you select. A keyed endpoint uses your provider account’s quota instead of a shared public limit.

  1. Open your provider dashboard, such as Infura, Alchemy or QuickNode, and create a key for a separate project for your wallet. Copy the HTTPS endpoint for the exact chain. The subdomain usually identifies the chain: Infura’s Ethereum mainnet format is https://mainnet.infura.io/v3/<KEY>, while Alchemy’s is https://eth-mainnet.g.alchemy.com/v2/<KEY>.

    Chainlist entries show EVM network chain IDs and public RPC details. Use Chainlist to find the network’s Chain ID and compare it with the provider endpoint’s chain. The provider dashboard supplies your keyed URL.

  2. In MetaMask, open Networks and edit the network you already use. In the RPC URL dropdown, choose Add RPC URL. On the extension, this is under Manage networks; in the mobile app, open the network dropdown and edit the network.

  3. Paste the HTTPS endpoint, give it a clear name such as “Ethereum — Alchemy wallet,” and select it as the default RPC URL. Save the change. If the network is not in MetaMask yet, add it first using its network details and Chain ID, then add your provider URL.

  4. Keep the key in its own provider project for the wallet. The key is part of the URL, so a screenshot or synced setting that exposes it could let someone use that key’s quota. A separate project lets you rotate the wallet key without changing keys used by your apps. After saving, confirm that your provider dashboard shows requests from the wallet; that’s the sign MetaMask is using your endpoint.

Resolve URL and Chain ID errors

Match the endpoint to the network’s Chain ID and use HTTPS to avoid common MetaMask RPC errors.

MetaMask says the chain ID returned by the RPC does not match

The endpoint is returning a different Chain ID from the one set for the MetaMask network. Check the provider’s chain-specific URL and compare the network’s Chain ID in MetaMask with the entry on Chainlist. JSON-RPC’s eth_chainId method returns the ID reported by the endpoint. Use an endpoint for the same chain before saving the URL.

Use a WebSocket URL in MetaMask

MetaMask needs the HTTPS endpoint for this RPC setting. A WebSocket URL starts with wss:// and will fail here; copy the provider’s HTTPS URL, which starts with https://, instead.

Related

Once the keyed HTTPS URL is selected and provider activity confirms requests, MetaMask is using your own RPC endpoint for that network.