I requested active account address from Metamask and received it successfully. After that I tried to authenticate user by signing data with eth.personal.sign, but getting errors unfortunately.

signMessage( publicAddress: string, nonce: number ): Promise<any> {
        return this.web3.eth.personal.sign(
            this.web3.utils.fromUtf8( `Sign: ${nonce}` ), publicAddress ).then( ( signature ) => {
            return signature;
        } )

Getting this error: Invalid Arguments length: expected: 3, given: 2 (guess need password as 3rd argument?)

When using eth.sign( hash, addr) it gives: Uncaught TypeError: t is not a function (inpage.js)

I was following this tutorial: https://www.toptal.com/ethereum/one-click-login-flows-a-metamask-tutorial, and here he doesn't need the account password to sign data.

Also, if I do this from the browser in my app it works, I get back the signature:

web3.eth.personal.sign('data','0x7567d83b7b8d80addcb281a71d54fc7b3364ffed',(err,sig) => console.log(sig) )

So what can be the difference? web3 from Metamask seems to be beta_37 while in my app beta_46, but now I am a bit lost.


  • I same error get to myself
    – Jim
    Oct 29, 2021 at 2:49

1 Answer 1


I'm the author of the article you linked.

eth.sign is deprecated for security reasons, so I wouldn't recommend using it. According to the docs, personal.sign does take 3 arguments (and an optional callback), the third argument being the password to unlock the account. In the case you're using MetaMask provider, the password is not needed, and you can pass an empty string '';

I have updated the code in my login-with-metamask-demo repo:

  const signature = await web3.eth.personal.sign(
    `I am signing my one-time nonce: ${nonce}`,
    '' // MetaMask will ignore the password argument here

This above snippet is copy-pasted from here.

  • why not make the password an optional argument rather than force the user to pass a pointless empty string? 🤔
    – Jim
    Oct 29, 2021 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.