[SOLVED] Verifying a signedMessage

const verifyResult = await web3.eth.personal.ecRecover(signedMessage, signature)

moralis Error: Returned error: the method personal_ecRecover does not exist/is not available
at handleError (RESTController.js:437)

any help?

have you tried to use web3.eth.accounts.recover instead?

trying now… no error, but unexpected result so far

will report back

It seems that we need to tweak config in our nodes to make web3.eth.personal work, will get back.
For now - hopefully you can solve your issue without personal package.

many thanks!
:pray: :muscle:

1 Like

Hey ivan, has there been progress on this matter?
I tried using web3.eth.personal.ecRecover on cloud functions and it doesn’t seem to work
this is what I get
Error: {“message”:“Invalid JSON RPC response: “Unauthorized””,“code”:141}

can you share a part of your code that you used?

hey cryptokid!
this is the code for signing:

const signed_message = await web3.eth.personal.sign(message, eth_address)

and this is the cloud function code for recovering:

const params = request.params
const message = params.message
const signed_message = params.signed_message
const web3 = Moralis.web3ByChain("0x1");
const recovered_eth_address = await web3.eth.personal.ecRecover(message, signed_message)

the cloud function fails right on the web3.eth.personal.ecRecover line.
message and signed_message is logged correctly in cloud functtion too.

1 Like

working code:

const web3 = Moralis.web3ByChain("0x1");  
message = "";
signed_message = "0x";
const recovered_eth_address = await web3.eth.accounts.recover(message, signed_message);

it worked! I guess it was web3 coding error than moralis error.
really appreciate your quick response and solution!
thanks cryptokid!

1 Like

Hey cryptokid, recovered_eth_address return undefined. Input parameters seems true. logger is
Ran cloud function verifySignature for user xxxxx with:
Input: {“message”:“test”,“signature”:“0xff…58”, address: “0x…”}
Result: undefined

My cloud function;
const params = request.params
const message = params.message
const signature = params.signature
const address = params.address
const recovered_eth_address = await web3.eth.accounts.recover(message, signature);
logger.info(“verifySignature result”,JSON.stringify(recovered_eth_address));

Logger.info doesn’t support two parameters

Does this have anything to do with result returning undefined?

This line doesn’t print the second parameter.
You have to return something to have a result

Oh right, I didn’t notice. Thank you so much. Its worked. So, what should this result mean for us? What should we match the returned result to?

The recovered eth address should be the address that signed that message

Thank you so much for your help :slight_smile:

1 Like