I want to sign message for login dapp,
The message is like "Welcome !" and have Nonce.
How can I using sign_message function with nonce?
In the Metamask show like below.
messagepythonweb3js
I want to sign message for login dapp,
The message is like "Welcome !" and have Nonce.
How can I using sign_message function with nonce?
In the Metamask show like below.
Use 0xfdba67e41f7c6767100969ae3f045d10a59e35d380acf5b37a3b208bd2969347
instead (with a 0x
prefix) so web3 knows the format of the private key:
web3.eth.accounts.privateKeyToAccount('0xfdba67e41f7c6767100969ae3f045d10a59e35d380acf5b37a3b208bd2969347').address
"0xa6CDA44CEA3Ac87435d9fDF548B051dDE90D128F"
Best Answer
Under the hood, it's just one message that you need to sign.
Some background on how it works. Let's use Nansen as an example as it's the closest to the one on your screenshot.
When you click "Sign in with Wallet" (e.g. MetaMask), the app server generates a message with a time to live & a nonce. Here's what the message looks like in the MetaMask UI:
And here's what's actually sent to you from the server:
So, you need to sign the entirety of this message as one with your private key:
Once you get the signature, you need to post it back to the app server within the time to live period so that you get signed in.