Metamask-extension: Error: WalletMiddleware - Invalid "from" address when try to web3.eth.sign()

Created on 7 Mar 2019  路  9Comments  路  Source: MetaMask/metamask-extension

Describe the bug
I am trying to write small DAPP with Angular 7, web3 & MetaMask.
When I call sign any message with my ETH account, I get MetaMask - RPC Error: Error: WalletMiddleware - Invalid "from" address. error.
I don't change active accounts, this is my only one accounts in MetaMask, I tried to get this accounts, from web3.eth.getAccounts()[0], manually, etc. Unfortunately nothing helps.

To Reproduce

const web3 = new Web3(Web3.givenProvider);
const accounts = await web3.eth.getAccounts();
console.log(accounts);
const sign = await web3.eth.sign('dataToSign', accounts[0]);

web3.eth.getAccounts() properly return my account.
I've disable privacy mode on MetaMask (not need to enable())

Expected behavior
I should be able to sign the message correctly.

Screenshots
github

Browser details (please complete the following information):

  • OS: Ubuntu 16.04
  • Browser: Chrome
  • MetaMask Version: 6.2.1
  • Angular 7
  • Web3 1.0.0-beta48

All 9 comments

I have the same problem

@mrejmicz did you figure this out?

@arnigudj Unfortunately not. I had this problem for last month. Any angular CLI, metamask, Web3 updates/version changes didn't help yet

Are you all including the user's active address in the from field of transaction parameters?

See these docs for more info. cc @tmashuang

@bdresser yes, passing the from address as described in the docs and getting that error.

I'm getting this issue since I upgraded web3 to 1.0.0-beta.48.

@mrejmicz I solved by installing the beta.37

make sure that it's "web3": "1.0.0-beta.37", not"web3": "^1.0.0-beta.37" in the package.json before running the npm install or yarn install

You can also try using web3.eth.personal.sign(message, address)

const web3 = new Web3(Web3.givenProvider);
const accounts = await web3.eth.getAccounts();
console.log(accounts);
const sign = await web3.eth.personal.sign('dataToSign', accounts[0]);

@arnigudj
Ok, so beta.37 version of web3, gave me another error, something like: https://ethereum.stackexchange.com/questions/66424/domexception-failed-to-execute-postmessage-on-window-error-when-using-metam

Trying to sign with web3.eth.personal.sign works properly, but on beta.38 this method required 3 parameters

const sign = await web3.eth.personal.sign('dataToSign', accounts[0], 'password');

It's a little bit strange, because 'password' can be any string, and don't be used at all :)
But it works, thanks a lot for help.
By the way, i think this is still problem on beta.38 and should be resolve.

@mrejmicz great find. summary:

for [email protected] the web3.eth.personal.sign requires a 3rd parameter, a password string (unused in metamask)

closing as not a metamask issue (again see ethereum/web3.js#2528)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hellobart picture hellobart  路  3Comments

whyrusleeping picture whyrusleeping  路  3Comments

bdresser picture bdresser  路  3Comments

BassBauman picture BassBauman  路  3Comments

aecc picture aecc  路  3Comments