// Web3 code
let amount = 55;
let messageToSign = `Please sign the message for claiming the reward amount of
${amount} tokens!`;
let signature = await web3_obj.eth.personal.sign(messageToSign, account.toString());
// Smart contract code to verify the signed message to get the signer's address
function getSigner(uint _amount, bytes memory _signature)
public
pure
returns(address) {
bytes32 _prefixHash =
ECDSA.toEthSignedMessageHash(keccak256(abi.encodePacked("Please sign the
message for claiming the reward amount of ", _amount, " tokens!")));
return ECDSA.recover(_prefixHash, _signature);
}