Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public testSignPersonalMessage = async () => {
const { walletConnector, address } = this.state;
if (!walletConnector) {
return;
}
// test message
const message = "My email is john@doe.com - 1537836206101";
// encode message (hex)
const hexMsg = convertUtf8ToHex(message);
// personal_sign params
const msgParams = [hexMsg, address];
try {
// open modal
this.toggleModal();
// toggle pending request indicator
this.setState({ pendingRequest: true });
// send message
const result = await walletConnector.signPersonalMessage(msgParams);
// verify signature
const signer = recoverPersonalSignature(result, message);
public testSignPersonalMessage = async () => {
const { web3, address } = this.state;
if (!web3) {
return;
}
// test message
const message = "My email is john@doe.com - 1537836206101";
// encode message (hex)
const hexMsg = convertUtf8ToHex(message);
try {
// open modal
this.toggleModal();
// toggle pending request indicator
this.setState({ pendingRequest: true });
// send message
const result = await web3.eth.personal.sign(hexMsg, address);
// verify signature
const signer = recoverPersonalSignature(result, message);
const verified = signer.toLowerCase() === address.toLowerCase();
// format displayed result