连接到 trustwallet 并获取 bsc、eth、btc 地址和余额

时间:2021-07-14 11:47:55

标签: ethereum web3 web3js binance-smart-chain wallet-connect

现在我使用这个代码: https://github.com/Web3Modal/web3modal-vanilla-js-example

但它只连接来自信任钱包的 eth 地址

我尝试将提供程序选项更改为:

const providerOptions = {
      walletconnect: {
        package: WalletConnectProvider,
        options: {
            rpc: {
            56: "https://bsc-dataseed.binance.org/"}
        }
      },

但是没有用

在我的信任钱包中,我有 btc 地址、eth 地址、bnb 地址,我想知道所有这些地址和余额。但是现在我只能得到eth地址

我尝试这样做:

const chainId = 56//await web3.eth.getChainId();
// Get list of accounts of the connected wallet
const accounts = await web3.eth.getAccounts();

但这仅给我 eth 帐户。 那我该怎么办?

1 个答案:

答案 0 :(得分:0)

您需要要求用户更改钱包本身中的链才能访问不同链上的帐户。目前没有 API 或方法可以强制用户更改链。