I am using 'web3.eth.sign` to sign a message, using following code snippet:

web3.eth.sign(msgHash, address, async (err, signedMsg) => {
  if(err) {
  } else {
    let { r,s,v } = await getRSV(signedMsg)
    resolve({ r,s,v })


address: 0x7b9f2B209A6CeF0525e49aE1409a21F3E6f33E6B
masgHash: 0x1df7d7e71ce2983d96a3579b72721945407e0b6887dfb20cc5d9dac03352e765

But this giver error

Node error: {"code":-32602,"message":"invalid argument 0: hex string has length 64, want 40 for common.Address"}


1 Answer 1


Looks like you're on web3.js v0.x, where the order of the first two arguments to this function is opposite to that of web3.js v1.x:

  • Thanks. I am using [email protected], so I was doing it right. I can verify that as when I switch the params, I get error: ` Error: Provided address "0x1df7d7e71ce2983d96a3579b72721945407e0b6887dfb20cc5d9dac03352e765" is invalid, the capitalization checksum test failed` Commented Mar 10, 2019 at 20:22
  • @PrashantPrabhakarSingh: You might want to try v37 or lower. I'm pretty sure that there are various problems in later versions (I'm personally staying at 34 for now). Commented Mar 10, 2019 at 20:25
  • Thanks for recommendation. Will switch to 34 :) Commented Mar 10, 2019 at 20:26
  • @PrashantPrabhakarSingh: With regards to your actual problem - have you made sure to use strings (and not numbers, since those would be too large for JS)? Commented Mar 10, 2019 at 20:26
  • 2
    Downgrading to v 34 resolved the issue. Thanks :) Commented Mar 10, 2019 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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