Skip to content

Instantly share code, notes, and snippets.

@nnkken
Created April 6, 2018 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nnkken/24b135f893210387767bbc3832cf463c to your computer and use it in GitHub Desktop.
Save nnkken/24b135f893210387767bbc3832cf463c to your computer and use it in GitHub Desktop.
Signature Test
<!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>
// 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