Can someone please teach/tell me which part I get it wrong for the following code?
I am trying to sign a message with the function sign(), which, could be verified with the function verifySignature(). I’ve tested function verifySignature() alone and it works, but, the function verifySignature() bugged.
Error message:
TypeError: Member “sign” not found or not visible after argument-dependent lookup in type(library ECDSA).
→ contracts/Sign.sol:15:34:
|
15 | bytes memory signature = ECDSA.sign(hash, signer);
| ^^^^^^^^^^
//----------------------------------Code----------------------------------
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import “@openzeppelin/contracts/utils/cryptography/ECDSA.sol”;
contract SignatureVerification {
using ECDSA for bytes32;
function sign(bytes32 messageHash) public view returns (bytes memory) {
// Sign the message hash with the contract owner's private key
bytes32 hash = messageHash.toEthSignedMessageHash();
address signer = address(this);
bytes memory signature = ECDSA.sign(hash, signer);
return signature;
}
}
Thank you for all of your help!