如何将WalletConnect限制为仅连接到Binance Smart Chain?

发布于 2025-02-11 17:06:00 字数 850 浏览 1 评论 0原文

我正在尝试创建一个仅适用于Binance智能链的DAPP。我已经使用了WalletConnect CDN:

<script src="https://cdn.jsdelivr.net/npm/@walletconnect/[email protected]/dist/umd/index.min.js"></script> 

在RPC部分中,我仅将RPC用于Binance智能链,如下所示:

 function getProvider() {
    // const provider = new WalletConnectProvider.default({
    //   infuraId: "27e484dcd9e3efcfd25a83a78777cdf1",
    // });

    var provider = new WalletConnectProvider.default({
      rpc: {
        56: "https://bsc-dataseed.binance.org",
      },
      // bridge: "https://bridge.walletconnect.org",
    });

    return provider;
  }

我试图将信任钱包连接到我的DAPP,但仅显示以太坊主网。我也可以提供完整的代码(目前这是一个非常简单的网站)。

有人可以告诉我如何将其仅限于BSC吗?

I am trying to create a Dapp which works on Binance Smart Chain only. I have used walletConnect CDN:

<script src="https://cdn.jsdelivr.net/npm/@walletconnect/[email protected]/dist/umd/index.min.js"></script> 

In the RPC section I have only used the rpc for binance smart chain like the following:

 function getProvider() {
    // const provider = new WalletConnectProvider.default({
    //   infuraId: "27e484dcd9e3efcfd25a83a78777cdf1",
    // });

    var provider = new WalletConnectProvider.default({
      rpc: {
        56: "https://bsc-dataseed.binance.org",
      },
      // bridge: "https://bridge.walletconnect.org",
    });

    return provider;
  }

I am trying to connect Trust Wallet to my dapp but it shows Ethereum Mainnet only. I can provide the complete code as well (it's a very simple site at this moment).

Can someone please tell me how do I limit it to only BSC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雾里花 2025-02-18 17:06:00

有趣的是,在4年内没有人回答这个问题,您可能已经找到了解决方案,如果我能找到这个问题,那么任何人都可以找到这个问题。所以这是答案。 Wallet Connect不允许所有网络实现。 BSC(Binance Smart Chain)也是不幸的人之一。如果您转到 https://example.wallet.walletconnect.org/ 并尝试连接您的网站。您将获得错误的错误,即BSC是错误的网络,请切换。

It is funny that in 4 years no one answered this question and probably you may have found your solution already, still if i can find this question with this query anyone can find it. So here is the answer. Wallet connect does not allow all the networks implementation. BSC (Binance smart chain) is also one of the unlucky one. If you go to https://example.walletconnect.org/ and try to connect your website. You will get the error that bsc is the wrong network please switch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文