We have a function:
function _validSignature(bytes memory signature, bytes32 msgHash) internal view returns (bool) {
return msgHash.toEthSignedMessageHash().recover(signature) == _signerAddress;
}
As i know toEthSignedMessageHash()
takes messageHash
as argument and recover()
takes messageHash
and signature
as argument. But i did not understand how writing code like this:msgHash.toEthSignedMessageHash().recover(signature)
working. Can you explain me this?
When i tried same thing like this:
function recoverAddress(bytes32 _hash) public returns(address recovered){
bytes32 signature = ECDSA.toEthSignedMessageHash(_hash);
recovered = ECDSA.recover(_hash, signature);
return recovered;
}
its giving error for ECDSA.recover()
.
Error:
Member "recover" not found or not visible after argument-dependent lookup in type(library ECDSA).
Why? Why my approach giving error?