0

I just want to hash the senders' address

    function myHash() public returns(string memory){
        return(keccak256(abi.encodePacked(msg.sender)));
    }

but no matter what I do I get the following error

TypeError: Return argument type bytes32 is not implicitly convertible to expected type (type of first return variable) string memory.

Is there any way to just hash the address?

1 Answer 1

0

Your return type (bytes32) doesn't match the declared return type (string).

Just change your function declaration for :

function hashSenderAddress() public view returns (bytes32) {
    return(keccak256(abi.encodePacked(msg.sender)));
}

A hash is not really a string, it's basically a 32 bytes number (for keccak256 at least). Any "string" representation of it are just hexadecimal formatting, but it's still a number being represented.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.