1

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
  • I am still looking for this
    – JSking
    Jul 27, 2021 at 15:02

1 Answer 1

2

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
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.