Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mrejmicz opened this issue Mar 7, 2019 · 9 comments
Closed

Comments

@mrejmicz
Copy link

mrejmicz commented Mar 7, 2019

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
@arnigudj
Copy link

I have the same problem

@arnigudj
Copy link

@mrejmicz did you figure this out?

@mrejmicz
Copy link
Author

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

@bdresser
Copy link
Contributor

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

See these docs for more info. cc @tmashuang

@arnigudj
Copy link

arnigudj commented Mar 13, 2019

@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]);

@mrejmicz
Copy link
Author

@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 mrejmicz reopened this Mar 14, 2019
@kumavis
Copy link
Member

kumavis commented Mar 19, 2019

@mrejmicz great find. summary:

for web3@1.0.0-beta.38 the web3.eth.personal.sign requires a 3rd parameter, a password string (unused in metamask)

@kumavis
Copy link
Member

kumavis commented Mar 19, 2019

see web3/web3.js#2528

@kumavis
Copy link
Member

kumavis commented Apr 4, 2019

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

@kumavis kumavis closed this as completed Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants