How to verify a signature in a Solidity contract

Sample code and tests

Here's some initial code and hardhat test, and a Sign Message with Ethers.js and Verify with Solidity Contract video from Taz.


Though you may be wondering what ecrecover is (it's a built in method for verifying signatures in Solidity) and why messages are signed again with "\x19Ethereum Signed Message:\n32".

The Magic of Digital Signatures on Ethereum has a lot of useful background.

In that article you'll also learn: