Created
October 15, 2021 10:53
-
-
Save Rhynorater/ee93f2f70919630c2f7b97ce4bde3994 to your computer and use it in GitHub Desktop.
Create JSON Wallet from Private Key and Password
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
var Web3 = require('web3'); | |
const fs = require('fs') | |
const inquirer = require('inquirer') | |
var questions = [ | |
{ | |
type: 'input', | |
name: 'privateKey', | |
message: "What is your privateKey?" | |
}, | |
{ | |
type: 'input', | |
name: 'password', | |
message: "What is your password?" | |
}, | |
{ | |
type: 'input', | |
name: 'outputFile', | |
message: "What is the output file name?" | |
} | |
] | |
inquirer.prompt(questions).then(answers => { | |
var web3 = new Web3(Web3.givenProvider); | |
var JsonWallet = web3.eth.accounts.encrypt(answers['privateKey'], answers['password']); | |
fs.writeFileSync(answers['outputFile'], JSON.stringify(JsonWallet)); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment