Web3modal provides ethereum wallet connect in dapp. I'd like to connect binance smart chain wallet extentions. I think it would be possible to edit providerOptions for the each wallet extensions. Anyone can give me detailed answer for my question? Thanks
1 Answer
The following piece of code is an extract of what I use in the dapp I've developed.
let providerOptions = {
"custom-binancechainwallet": {
display: {
logo: "../../assets/img/binance-logo.svg",
name: "Binance Chain Wallet",
description: "Connect to your Binance Chain Wallet"
},
package: true,
connector: async () => {
let provider = null;
if (typeof window.BinanceChain !== 'undefined') {
provider = window.BinanceChain;
try {
await provider.request({ method: 'eth_requestAccounts' })
} catch (error) {
throw new Error("User Rejected");
}
} else {
throw new Error("No Binance Chain Wallet found");
}
return provider;
}
}
};
let web3Modal = new Web3Modal({
cacheProvider: true,
providerOptions,
disableInjectedProvider: false
});