web3modal icon indicating copy to clipboard operation
web3modal copied to clipboard

Does it support BSC?

Open dlpigpen opened this issue 3 years ago • 4 comments

and if Yes, is there any example to do?

dlpigpen avatar Apr 22 '21 22:04 dlpigpen

It supports custom networks so I assume it supports BSC too.

Define your provider options like this;

    const providerOptions = {
        walletconnect: {
            package: WalletConnectProvider,
            options: {
            rpc: {
                NETWORKID: "https://YOURPROVIDER"
            },
            network: "bsc"
            }
        }
    };

Then use;

try {
        provider = await web3Modal.connect();
    } catch(e) {
        onConnectError();
    }

Also if you want to make sure user is on same network, while interacting, use;

const chainId = await web3.eth.getChainId();
    if(chainId != YOURCHAINID) {
        alert("Wrong network! Switch to BSC");
        return;
    }

Also add

 CHAINID: {
                chainId: CHAINID,
                chain: "BSC",
                network: "BSC",
                networkId: NETWORKID
            }

to the library. It should be around on line 11K, simply CTRL+F and search for callisto-testnet, add yours below that

nithronium avatar May 14 '21 20:05 nithronium

It supports custom networks so I assume it supports BSC too.

Define your provider options like this;

    const providerOptions = {
        walletconnect: {
            package: WalletConnectProvider,
            options: {
            rpc: {
                NETWORKID: "https://YOURPROVIDER"
            },
            network: "bsc"
            }
        }
    };

Then use;

try {
        provider = await web3Modal.connect();
    } catch(e) {
        onConnectError();
    }

Also if you want to make sure user is on same network, while interacting, use;

const chainId = await web3.eth.getChainId();
    if(chainId != YOURCHAINID) {
        alert("Wrong network! Switch to BSC");
        return;
    }

Also add

 CHAINID: {
                chainId: CHAINID,
                chain: "BSC",
                network: "BSC",
                networkId: NETWORKID
            }

to the library. It should be around on line 11K, simply CTRL+F and search for callisto-testnet, add yours below that

   const providerOptions = {
      /* See Provider Options Section */
      walletconnect: {
        package: WalletConnectProvider, // required
        options: {
          rpc: { 56: 'https://bsc-dataseed1.defibit.io/', },
          network: "binance",
        }
      },
      // Other Providers Go Here
    };

You can switch out "https://bsc-dataseed1.defibit.io/" to any other BSC RPC Node that you want.

In the Code it accepts binance as the network.

You dont have to do the extra steps as long as you put network as binance

BryantS11 avatar Jun 14 '21 01:06 BryantS11

BSC testnet was not supported yet. https://github.com/Web3Modal/web3modal/blob/72596699b97d231dfaa5ef04110b61b8dc77d57d/src/helpers/utils.ts#L198

The main reason is Trust Wallet or other wallet does not have chain_id 97 built-in so if Walletconnect supports it, it still does not make the perfect couple.

luatnd avatar Dec 20 '21 19:12 luatnd

oh no 🤣

ricburton avatar Dec 20 '21 19:12 ricburton

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.

xzilja avatar Jan 21 '23 14:01 xzilja