我开始在我的dapp中使用Binance链钱包,所以我现在可以使用:
import { BscConnector } from '@binance-chain/bsc-connector'
export const bsc = new BscConnector({
supportedChainIds: [56, 97] // later on 1 ethereum mainnet and 3 ethereum ropsten will be supported
})
// invoke method on bsc e.g.
await bsc.activate();
await bsc.getAccount();
await bsc.getChainId();但是在API文档中,它说要执行一些链操作,我需要弹出:
BinanceChain和MetaMask最大的区别在于我们向网页注入了BinanceChain而不是web3。这样用户就可以同时保留两个扩展。
BinanceChain.request({method: "eth_sign", params: ["address", "message"])我用的是元
ethereum.request(...)你能给我解释一下怎么做吗?未声明BinanceChain obj :)
发布于 2022-01-20 19:28:01
因此,我发现这些步骤必然是:
//创建bsc钱包实例
const bsc = new BscConnector({
supportedChainIds: [56, 97, 1] // later on 1 ethereum mainnet and 3 ethereum ropsten will be supported
})//从此实例中获取提供者:
const bsc_provider = await bsc.getProvider()
provider = new ethers.providers.Web3Provider(bsc_provider)//从这里开始,您可以使用所有的二进制钱包功能:
provider.provider.switchNetwork('eth-mainnet')
见docs:二进制钱包文档
https://stackoverflow.com/questions/69945023
复制相似问题