gnx*_*xvw 4 ethereum solidity web3js
accounts[0]undefined在这段代码中返回。
const accounts = await web3.eth.getAccounts()
console.log(accounts[0])
我卸载了 Metamask 并重置了帐户,但这不起作用。
web3版本是web3@1.0.0-beta.37。
您能给我任何建议吗?为什么我无法从 Metamask 获得帐户地址?
存在 Metamask 连接错误。我通过编码连接到 web3。
Web3(window.web3.currentProvider)
然而,这个代码更适合现代钱包。
web3 = new Web3(window.ethereum)
    window.ethereum.enable().catch(error => {
        // User denied account access
        console.log(error)
    })
| 归档时间: | 
 | 
| 查看次数: | 8204 次 | 
| 最近记录: |