MetaMask - RPC Error: eth_sign requires 32 byte message hash

Hello, I got problem with your .Net core demo, it comes at the signing message step. I am using your sample client and server code at the tutorial: https://docs.moralis.io/web3-data-api/quickstart-dot-net-csharp

MetaMask - RPC Error: eth_sign requires 32 byte message hash {code: -32602, message: 'eth_sign requires 32 byte message hash'}

Please help, thank you

Hello,
Did you get a message to sign? at what step you got that error?

What line generates that error?

Hi,

The server successfully response the sign message. At this line of code in js file, I got the error:
// 6. Request that the user sign the message
const signature = await web3.eth.sign(msg.message, selectedAccount);

can you add a console.log(msg.message) to see if it has the expected data?

example.com wants you to sign in with your Ethereum account:
0x51A4F80c8aE58DFCE0B4AC0761592dDFCF99f73f

Please confirm

URI: https://example.com
Version: 1
Chain ID: 56
Nonce: MABYWa9ccRE2K8a0j
Issued At: 2023-01-12T20:09:45.798Z
Expiration Time: 2023-01-12T21:09:44.4005055Z
Not Before: 2023-01-12T20:09:44.4005526Z
Resources:
- https://www.1155project.com

I think this is the expected data, is this related to eth_sign?

And I am using BNB chain, I think it works with chainId = 56

where from you have this code? it should be personal sign used instead of eth.sign

Hi, I downloaded it from the tutorial. What should it be?

It works now! Please update the demo source, this helps other save their time.

Thanks alot for your help.

What was the link to the tutorial?

it’s here, in section 5

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.