Last active
August 20, 2021 07:28
-
-
Save VictorNS69/b5489a630ceff6e5877cc27d7b217ef4 to your computer and use it in GitHub Desktop.
Creates a new Ethereum Keystore
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
// Usage: node create_eth_keystore.js | |
// Node v10+ | |
// Dependencies | |
// npm i [email protected] | |
const Wallet = require('ethereumjs-wallet') | |
const accountPassword = "" // Put here the password you want for your keystore | |
const key = Wallet.generate(accountPassword) | |
const privateKey = key._privKey | |
const wallet = Wallet.fromPrivateKey(privateKey) | |
const keystoreData = wallet.toV3String(accountPassword) | |
const address = "0x" + JSON.parse(keystoreData).address | |
console.log("Account Address:", address) | |
console.log("Public key:", wallet.getPublicKeyString()) | |
console.log("Private key:", wallet.getPrivateKeyString()) | |
console.log("Keystore:\n", JSON.stringify(JSON.parse(keystoreData), null, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! I have edited the code 😄