Created
September 12, 2018 08:41
-
-
Save dcb9/5ec32843d1d5bac33f55d5e930601c2b to your computer and use it in GitHub Desktop.
qtum account
This file contains hidden or 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 { PrivateKey, Networks } = require('qtumcore-lib'); | |
// Qtum address is 'qUbxboqjBRp96j3La8D1RYkyqx5uQbJPoW' | |
// | |
// /dapp # qcli gethexaddress qUbxboqjBRp96j3La8D1RYkyqx5uQbJPoW | |
// 7926223070547d2d15b2ef5e7383e541c338ffe9 | |
const privateKey = PrivateKey.fromWIF('cMbgxCJrTYUqgcmiC1berh5DFrtY1KeU4PXZ6NZxgenniF1mXCRk'); | |
const privateKeyHex = '0x' + privateKey.toString().padStart(64, '0'); | |
console.log(privateKeyHex); | |
const publicKey = privateKey.toPublicKey(); | |
const address = publicKey.toAddress(Networks.testnet); | |
console.log(address); | |
const Web3 = require('web3'); | |
const web3 = new Web3(); | |
const message = "hi"; | |
const signature = web3.eth.accounts.sign(message,privateKeyHex); | |
console.log("signature", signature); | |
const signer = web3.eth.accounts.recover(message, signature.signature); | |
console.log(signer); | |
// output: 0x6Fd56E72373a34bA39Bf4167aF82e7A411BFED47 |
This file contains hidden or 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
{ | |
"name": "test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"qtumcore-lib": "0.0.1", | |
"web3": "^1.0.0-beta.36" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment