Skip to content

Instantly share code, notes, and snippets.

@Rhynorater
Created October 15, 2021 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rhynorater/ee93f2f70919630c2f7b97ce4bde3994 to your computer and use it in GitHub Desktop.
Save Rhynorater/ee93f2f70919630c2f7b97ce4bde3994 to your computer and use it in GitHub Desktop.
Create JSON Wallet from Private Key and Password
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