Binance Smart Chain (BSC) Error!
Hello, I am trying to use walletConnect to connect to BSC. I am giving the params as:
package: WalletConnectProvider,
options: {
rpc: {
56: 'https://bsc-dataseed1.defibit.io/'
},
chainId: 56,
}
}
I am getting error:
index.ts:74 POST https://mainnet.infura.io/v3/ 401

When adding the infuraId i am getting chainId 1 in provider network settings. Since I am using the provider to connect to a smart contracts in that network, I cannot connect because the chainId is wrong.
Did you ever fix this?
Try it:
const web3Modal = new Web3Modal({
network: "binance", // replace mainnet to binance
cacheProvider: true, // optional
providerOptions, // required
});
Yes @assertdesignuk , I used:
providerOptions = {
walletconnect: {
package: WalletConnectProvider,
options: {
rpc: {
56: 'https://bsc-dataseed.binance.org/'
},
network: 'binance',
chainId: 56,
infuraId: YOUR_INFURA_KEY,
}
}
};
@ochikov I just copied your code, but it not worked. Could you please tell me your WalletConnectProvider version and web3Modal version? Does these options work for BSC testnet?
No, works only for mainnet. My provider is ethers.js web3provider
Currently, I'm combing through the Infura documentation and I don't see that Binance is supported at the moment. Or am I missing a configuration somewhere that I can toggle Binance support?
I'm also very curious about this. :)
@djmbritt @danielmedvec I just set the provider options like this.
const providerOptions = {
walletconnect: {
package: WalletConnectProvider,
options: {
rpc: {
56: 'https://bsc-dataseed.binance.org/'
},
network: 'binance',
}
}
};
and then
const web3Modal = new Web3Modal({
cacheProvider: true, // optional
providerOptions // required
});
const provider = await web3Modal.connect();
const web3 = new Web3(provider);
Make sure you are using the latest version of web3modal package.
thanks these posts have been very useful to me. I can't understand one thing though.
why use infuriaId if we can use bsc-dataseed.binance.org directly?
are there any differences? furthermore infuriaId is paid
@djmbritt @danielmedvec I just set the provider options like this.
const providerOptions = { walletconnect: { package: WalletConnectProvider, options: { rpc: { 56: 'https://bsc-dataseed.binance.org/' }, network: 'binance', } } };and then
const web3Modal = new Web3Modal({ cacheProvider: true, // optional providerOptions // required }); const provider = await web3Modal.connect(); const web3 = new Web3(provider);Make sure you are using the latest version of
web3modalpackage.
i am trying to get it to work with both BSC and ETH Mainnet, is it possible?
On my site one page uses BSC and on the other ETH, how can I implement this system to make it work on both sides? or force a refresh in the page change?
const providerOptions = {
walletconnect: {
package: WalletConnectProvider,
options: {
rpc: {
56: 'https://bsc-dataseed.binance.org/',
1: 'https://mainnet.infura.io/v3/',
},
infuraId: "INFURA_ID",
}
}
};
Anyone found how to add options to swap between ETH and BSC?
With stable version 2.0.0 of Web3Modal now released, we are officially dropping support for version 1.x Due to this this issue/pr was marked for closing. It is highly recommended to upgrade as 2.x will be receiving further updates that will enable functionality for some of our newer sdks like auth and push as well as support for WalletConnect v2 (See this post about WalletConnect v1 being deprecated https://medium.com/walletconnect/walletconnect-v1-0-sunset-notice-and-migration-schedule-8af9d3720d2e)
If you need to continue using Web3Modal 1.x and require this feature/fix implemented, we suggest adding it via forking V1 branch.