Created
April 6, 2018 05:01
-
-
Save nnkken/24b135f893210387767bbc3832cf463c to your computer and use it in GitHub Desktop.
Signature Test
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> | |
<title>Signature Test</title> | |
</head> | |
<body> | |
<div id="from"></div> | |
<div id="sig"></div> | |
<script src="dist/index.js"></script> | |
</body> | |
</html> |
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
// need webpack or other bundler to use web3, output to dist/index.js | |
var Web3 = require("web3"); | |
window.setTimeout(function() { | |
var web3 = new Web3(window.web3.currentProvider); | |
var from; | |
var e = document.getElementById('from'); | |
web3.eth.getAccounts().then((accs) => { | |
console.log(accs); | |
e.innerHTML = 'ACCOUNTS: ' + accs; | |
from = accs[0]; | |
e = document.getElementById('sig'); | |
return web3.eth.personal.sign("Hi", from); | |
}).then((sig) => { | |
console.log(sig); | |
e.innerHTML = sig; | |
}).catch((err) => { | |
console.log(err); | |
e.innerHTML = 'ERROR: ' + err; | |
}); | |
}, 500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment