Hashing --- get Signature

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);
| ^^^^^^^^^^


// 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!

Please rephrase your (buggy) question.

This error-message tells you pretty clearly what the problem is:
The ECDSA library does not expose a function named sign.

Looking into that library on GitHub, and indeed - it does not expose a function named sign.

Hi, thank you for your prompt reply.

May I pls ask do you know other methods that I could do to achieve the goal to sign a message?

Also tried the following libraries/packages, but yet still doesn’t work.
(i) keccak256
(ii) TypedData
(iii) EIP712

Using the build-in sign function is my last move if all of these doesn’t work out.