我的工作我的第一个DAPP,我试图用WEB3和MetaMask签署的消息,但我不断收到此错误:
inpage.js:1 MetaMask - RPC Error: Error: WalletMiddleware - Invalid "from" address.
我有MetaMask隐私模式关闭。所述getCoinBase()方法被正确返回我在MetaMask选择的地址。但是,当我尝试使用它签署的消息这是行不通的。
这里是我的代码:点的线来跳过不重要的部分。
let Web3 = require('web3')
.
.
.
constructor(props) {
super(props);
if (typeof web3 != 'undefined') {
// eslint-disable-next-line no-undef
this.web3 = new Web3(web3.currentProvider);
}
this.web3.eth.getCoinbase()
.then(account => {
this.web3.eth.sign('test message', account);
});
}
Metamask最近做了关于他们如何显示地址用户更改。我发现,似乎与here出现StackOverflow职位。报价:
The Invalid address error can also happen if you haven't called window.ethereum.enable(); yet.
相关博客文章从Metamask团队:https://medium.com/metamask/https-medium-com-metamask-breaking-change-injecting-web3-7722797916a8