0

I'm trying to interact with a smart contract in python. With Metamask i can see, that there is a signature trasferred to verify my wallet. Now the point is how to calculate this signature to use a python script. On the contract side, the signature will be compared with a calculated signature on the server:

bytes32 message = keccak256(abi.encodePacked(msg.sender, address(this)));
    require(verifier.verify(message, _signature), "INVALID_SIGNATURE");

function verify(bytes32 _message, bytes memory _signature) external view returns (bool);

I assume that msg.sender will be my wallet adress but not sure about the other one?

Any links to read more about this topic would also be helpful! Thank you.

1
  • keccak256 is a generic hashing function. It can take any string as an input. If your question is about abi.encodePacked, you can read about what that does in the docs. Commented Apr 11, 2022 at 14:22

1 Answer 1

0

Keccak256()takes in byte arrays (bytes) as input.abi.encodePacked or abi.encode turns input parameters into byte arrays. If by 'the other one', you mean address(this), it refers to the address of the instance of this smart contract. Note that msg.sender may not always be an EOA, it might also be a smart contract that invokes the function. It might be helpful to provide more context. In this case, it seems message takes in your account address and the smart contract address and create a Hash that compares with _signature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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