Created
August 14, 2018 15:55
Star
You must be signed in to star a gist
Metamask signing form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<!-- | |
Created using JS Bin | |
http://jsbin.com | |
Copyright (c) 2018 by anonymous (http://jsbin.com/fovamotoca/2/edit) | |
Released under the MIT license: http://jsbin.mit-license.org | |
--> | |
<meta name="robots" content="noindex"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<textarea id='pvt'> | |
message to be signed | |
</textarea> | |
<br> | |
<input type='button' value='Sign' onclick='sign()'/> | |
<br> | |
Hash of message to sign: | |
<br> | |
<span id='hashpvt'> | |
</span> | |
<br> | |
Signed object: | |
<br> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"></script> | |
<textarea id='pvtsigned'> | |
</textarea> | |
<script> | |
function sign() { | |
var msg = $('#pvt').text() | |
var msgToSign = web3.sha3(msg); | |
$('#hashpvt').text(msgToSign); | |
web3.eth.sign(web3.eth.coinbase, msgToSign, function(err, signature) { | |
if(err) { | |
$('#pvtsigned').text(err); | |
return; | |
} | |
var signed = { | |
signature: signature, | |
signed_message: msgToSign, | |
origin_message: msg | |
}; | |
$('#pvtsigned').text(JSON.stringify(signed, null, 4)) | |
}) | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment