Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let msgParams = [
{
type: 'string', // Any valid solidity type
name: 'Message', // Any string label you want
value: 'Vote for ' + candidateName // The value to sign
}
]
var from = web3.eth.accounts[0]
var params = [msgParams, from]
var method = 'eth_signTypedData'
console.log("Hash is ");
console.log(sigUtil.typedSignatureHash(msgParams));
web3.currentProvider.sendAsync({
method,
params,
from,
}, function (err, result) {
if (err) return console.dir(err)
if (result.error) {
alert(result.error.message)
}
if (result.error) return console.error(result)
$("#msg").html("User wants to vote for " + candidateName + ". Any one can now submit the vote to the blockchain on behalf of this user. Use the below values to submit the vote to the blockchain");
$("#vote-for").html("Candidate: " + candidateName);
$("#addr").html("Address: " + from);
$("#signature").html("Signature: " + result.result);
console.log('PERSONAL SIGNED:' + JSON.stringify(result.result))