-
-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hasMessage doesn't return the same result as ECDSA.toEthSignedMessageHash #2978
Comments
Need to see implementation of |
Hello @netanel-utila. Please provide a minimal reproduction using StackBlitz, TypeScript Playground (for type issues), or a separate minimal GitHub repository. Minimal reproductions are required as they save us a lot of time reproducing your config/environment and issue, and allow us to help you faster. Once a minimal reproduction is added, a team member will confirm it works, then re-open the issue. |
Using etherjs gives the correct result: const encodedData2 = ethers.utils.solidityPack(
['address'],
['0x2caB3e8CB41eAbf14A2AD1A7bbb6F48b99A371FB']
);
const hash2 = ethers.utils.keccak256(encodedData2);
// Using ethers.utils.hashMessage to apply the Ethereum-specific prefix for signing
const prefixedHash = ethers.utils.hashMessage(ethers.utils.arrayify(hash2));
console.log({
hash,
hashMessage: prefixedHash,
}); |
You need to pass the raw representation of the message via the hashMessage({ raw: hash }) |
This issue has been locked since it has been closed for more than 14 days. If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread. |
Check existing issues
Viem Version
2.21.40
Current Behavior
The output of the following code is:
When running the same functionality in Solidity (Remix IDE) the hash is the same but hashMessage is not:
Expected Behavior
Both messageHash should produce the same result
Steps To Reproduce
No response
Link to Minimal Reproducible Example
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: