简体   繁体   English

如何将 BSC 与 WalletConnect 和 Web3.js 一起使用

[英]How to use BSC with WalletConnect and Web3.js

Like the title says, i need to integrate these technologies together.正如标题所说,我需要将这些技术整合在一起。

I instantiate WalletConnectProvider like this, as per docs:根据文档,我像这样实例化 WalletConnectProvider:

const provider = new WalletConnectProvider({
rpc:'https://bsc-dataseed.binance.org/'
});

//  Enable session (triggers QR Code modal)
await provider.enable();
web3=new Web3(provider);

But whenever i make a call to a Smart Contract deployed in there, it won'be called.但是每当我调用部署在那里的智能合约时,它就不会被调用。 Also, it uses the Trust Wallet ETH account, not the BSC one.此外,它使用 Trust Wallet ETH 帐户,而不是 BSC 帐户。

Any help would be appreciated.任何帮助,将不胜感激。

when specifying the rpc link, try creating an object for it with the key as the chain Id and the value as the provider url指定 rpc 链接时,尝试为其创建一个 object,键为链 ID,值为提供者 url

rpc = {
  57: "https://your-bsc-provider-url-here.com"
};

Check the custom RPC instructions here https://docs.walletconnect.com/quick-start/dapps/web3-provider在此处查看自定义 RPC 说明https://docs.walletconnect.com/quick-start/dapps/web3-provider

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM