Created
June 9, 2017 05:55
-
-
Save sogoiii/05a2f9c0cc01c3f1dffc7296ab04591e to your computer and use it in GitHub Desktop.
Create Ethereum Signatures
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
const Web3 = require('web3') | |
const provider = new Web3.providers.HttpProvider('http://localhost:8545') | |
const web3 = new Web3(provider) | |
function toHex(str) { | |
var hex = '' | |
for(var i=0;i<str.length;i++) { | |
hex += ''+str.charCodeAt(i).toString(16) | |
} | |
return hex | |
} | |
let addr = web3.eth.accounts[0] | |
let msg = 'I really did make this message' | |
let signature = web3.eth.sign(addr, '0x' + toHex(msg)) | |
console.log(signature) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment