1

I'm trying to call web3's eth_sign with metamask's provider, like so

        var signature = await web3.eth.sign(web3.utils.utf8ToHex(randomMsg),acc0)

The metamask windows notification pops up and everything works correctly, I click on Sign and it seems to work since the loading finishes and I'm returned to the list of transactions, but the notification never closes and the eth_sign promise never resolves.

I'm using web3.js version 1.2.4 and the latest metamask. I've tried updating to the 2.0.0 alpha version of Web3 but the same happened.

John Smith
  • 75
  • 9

2 Answers2

2

I ended up using the web3.eth.personal.sign function instead. I thought I needed to add a password but it turns out if I don't add a password to the function parameters, it will use metamask to sign.

John Smith
  • 75
  • 9
1

You must to encrypt your message by web3.utils.sha3 instead of web3.utils.utf8ToHex.

dzhere
  • 11
  • 1