Skip to content

Unable to recover signer from hash and signature using viem but works for ethers.js #1685

Answered by jxom
tomarsachin2271 asked this question in Question
Discussion options

You must be logged in to vote

Looks like the hash uses a EIP-191 prefix. So you would need to use recoverMessageAddress (recoverAddress is the raw version of this, and recoverMessageAddress uses it internally but also adds on the prefix).

await recoverMessageAddress({
  message: { raw: '0x2a87193349a393ba9a914af959b532120dfb2a2bc7aeabd7de344dd711bb92fc' },
  signature: '0x5ae4e70321e29afe793c5d00711c72716febced4e7944233c7788dacb242325e4c6bc072a509d52aebaee8baab7294017ee3cdb94b37da545b29cb678cd0b5a91b',
})

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@tomarsachin2271
Comment options

@tmm
Comment options

tmm Jan 15, 2024
Maintainer

Answer selected by tomarsachin2271
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants