Created
May 13, 2018 19:29
-
-
Save GrandSchtroumpf/fe5b6764606c2259e3e8966f1c04b48a to your computer and use it in GitHub Desktop.
A HDWallet for Ethereum
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 bip39 = require('bip39'); | |
const HDKey = require('hdkey'); | |
const Web3 = require('web3'); | |
const web3 = new Web3('https://ropsten.infura.io/your-id'); | |
const mnemonic = bip39.generateMnemonic(); | |
confirm(mnemonic); | |
const seed = bip39.mnemonicToSeed(mnemonic); | |
const masterNode = HDKey.fromMasterSeed(seed); | |
const derivationKey = "m/44'/60'/0'/0'/0"; | |
const account = masterNode.derive(derivationKey); | |
const privateKey = account._privateKey.toString('hex'); | |
const web3Account = web3.eth.accounts.privateKeyToAccount(privateKey); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment