Skip to content

Instantly share code, notes, and snippets.

@diegofcornejo
Created February 4, 2022 05:15
Show Gist options
  • Select an option

  • Save diegofcornejo/7ff2a516ab6851a7870dffc10dd803d5 to your computer and use it in GitHub Desktop.

Select an option

Save diegofcornejo/7ff2a516ab6851a7870dffc10dd803d5 to your computer and use it in GitHub Desktop.
Metamask ETH - NodeJS Signature verifier
const ethSigUtil = require("@metamask/eth-sig-util");
const address = '0x0';
const message = 'Hi I am 0x0';
const signature = '0x0';
let checkSignature = (data, signature) => {
const params = {
data,
signature
};
return ethSigUtil.recoverPersonalSignature(params);
}
console.log(checkSignature(message, signature));
if(checkSignature(message, signature).toLowerCase() === address.toLowerCase()) {
console.log('Signature is correct');
}else {
console.log('Signature is incorrect');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment