Created
June 16, 2019 12:02
-
-
Save n1c01a5/5247e02a6a8a8370911d033c38238c2a to your computer and use it in GitHub Desktop.
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
function generateSeedWallet() { | |
const bip39 = require('bip39') | |
const hdkey = require('ethereumjs-wallet/hdkey') | |
const mnemonic = bip39.generateMnemonic() //generates string | |
const seed = bip39.mnemonicToSeedSync(mnemonic).toString('hex') | |
const hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(seed)) | |
const wallet_hdpath = "m/44'/60'/0'/0/" | |
const wallet = hdwallet.derivePath(wallet_hdpath + 0).getWallet() | |
const address = '0x' + wallet.getAddress().toString('hex') | |
const privateKey = wallet.getPrivateKey().toString('hex') | |
return {mnemonic, address, privateKey} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment