Here is an article with a solution for the issue you are facing:
Ethereum: Unsupported keys: rpcUrl when added Binance Smart Chain to MetaMask using ethers.js
Are you having trouble adding the Binance Smart Chain (BSC) network to your MetaMask wallet using ethers.js? You’ve probably encountered an “Unsupported Keys” error, which can be frustrating. In this article, we will explore why this error occurs and provide a solution to add the BSC network to your MetaMask wallet.
What’s going on with ethers.js?
Ethers.js is a popular JavaScript library for interacting with the Ethereum blockchain. When you try to add the Binance Smart Chain (BSC) network to your MetaMask wallet using ethers.js, there are several potential issues that could be causing the “Unsupported Keys” error.
The Problem: Unsupported Keys
When adding the BSC network to a new MetaMask wallet, ethers.js requires a specific RPC URL (rpcUrl
) to establish communication with the Ethereum blockchain. However, if this RPC URL is not configured correctly, ethers.js will throw an “unsupported keys” error.
Why does this happen?
Here are a few reasons why ethers.js may throw an “unsupported keys” error when adding the BSC network:
- Incorrect RPC URL – If the
rpcUrl
is incorrect or missing, ethers.js may not be able to communicate with the Ethereum blockchain.
- Incorrect Provider Configuration
– When using a web3 provider like MetaMask, you need to configure the provider correctly to use the BSC network.
- Incompatible Wallets: Some wallets, including MetaMask, may not support the addition of the BSC network.
How to add Binance Smart Chain to your MetaMask wallet
To add the BSC network to your MetaMask wallet using ethers.js, follow these steps:
- Install ethers.js:
npm install ethers.js
oryarn add ethers.js
- Initialize a new MetaMask wallet with the “Binance Smart Chain” provider:
new Web3.providers.HttpProvider("
- Use theethers.js
library to interact with your wallet:
const web3 = new Web3(provider);`
Solution:
To fix the “Unsupported keys” error, try the following:
- Check your RPC URL: Make sure you are using the correct RPC URL for your MetaMask provider.
- Check provider settings: Check that you have configured your wallet correctly to use the BSC network.
- Use a supported wallet: Try using a different wallet that supports adding the BSC network, such as Metamask or Trust Wallet.
Sample code:
Here is an example of how you can add the BSC network to your MetaMask wallet using ethers.js:
const Web3 = require('web3');
const providers = new Web3.providers.HttpProvider("
const web3 = new Web3(provider);
// Add Binance Smart Chain to your MetaMask wallet
web3.eth.addChain({
chainId: 100, // BSC network chain ID
name: "Binance Smart Chain",
});
// Get the list of available chains
web3.eth.getChainId(), web3.eth.chainId();
If you follow these steps and use a supported library like ethers.js, you should be able to add the BSC network to your MetaMask wallet successfully. If you still have problems, feel free to ask!