I have implemented the code which is creating new wallet but I am not able to get the private key of that wallet. Can anyone tell me like what is the proper way in which I can create new wallet which can provide me the private key as well using node.

my code:-

web3.personal.newAccount(name, function (err, res) {
        if (err) {
        } else {
            next(null , res);

2 Answers 2

//generate private key    
privateKey = web3.eth.accounts.create().privateKey.substr(2)

//generates pubKey from privateKey, encrypts it and store in keystore folder.
web3.eth.personal.importRawKey(privateKey, pin)
    .then((result) => {

    //store pub address.
    publicAddr = web3.utils.toChecksumAddress(result)

Sort of a similar question was also posted here: How to generate Ethereum wallets & keys on serverside with JS?


First get a INFURA NODE URL by signing up and creating a project on https://infura.io/

I did it using the following code

const Web3 = require('web3');
var web3provider = "https://INFURA_URL";
var web3 = new Web3(new Web3.providers.HttpProvider(web3provider));
var account = web3.eth.accounts.create();

You will get the public and the private key and a new account will be created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.