现在,我使用以下代码:https://github.com/Web3Modal/web3modal-vanilla-js-example
但它只连接来自trust wallet的eth地址
我尝试将提供程序选项更改为以下内容:
const providerOptions = {
walletconnect: {
package: WalletConnectProvider,
options: {
rpc: {
56: "https://bsc-dataseed.binance.org/"}
}
},但没有起作用
在我的信托钱包中,我有btc地址,eth地址,bnb地址,我想知道所有这些地址和余额。但是现在我只能得到他的地址
我试着这样做:
const chainId = 56//await web3.eth.getChainId();
// Get list of accounts of the connected wallet
const accounts = await web3.eth.getAccounts();但这只给我提供了eth帐户。那我该怎么办呢?
发布于 2021-07-14 19:50:00
您需要要求用户更改钱包本身中的链,才能访问不同链上的帐户。目前还没有强制用户更改链的API或方法。
发布于 2021-12-15 21:10:08
在我的例子中,它在Trust wallet上工作,在metamask移动应用程序上不工作:
walletconnect: {
package: WalletConnectProvider, // required
options: {
rpc: {
56: 'https://bsc-dataseed.binance.org/',
97: 'https://data-seed-prebsc-1-s1.binance.org:8545/',
},
network: "binance", // --> this will be use to determine chain id 56
},
},我不确定下面的代码是不是必需的:
web3Modal = new Web3Modal({
network: 'binance', // optional
cacheProvider: true,
providerOptions, // required
})您可以通过直接阅读源代码了解如何进行配置: //选择BSC work on Trust wallet但how on metamask https://github.com/Web3Modal/web3modal/blob/72596699b97d231dfaa5ef04110b61b8dc77d57d/src/providers/connectors/walletconnect.ts#L30 https://github.com/Web3Modal/web3modal/blob/72596699b97d231dfaa5ef04110b61b8dc77d57d/src/helpers/utils.ts#L198
https://stackoverflow.com/questions/68377493
复制相似问题