Background There are 2 different ways in order to create accounts with web3.

1. web3.eth.personal.newAccount(password, [callback])
2. web3.eth.accounts.create([entropy]);

SEcond options returns object which contains private key of account which is great . But in order to unlock account I have to use

web3.eth.personal.unlockAccount(fromAccount,password).then(function (result) {

In Web3 docs website they say these methods are //TODO getAccounts, unlockAccount, lockAccount, sendTransaction My questions

  1. How to unlockAccount created with 2 option (not personal)

  2. How to get private key from 1 option (personal.newAccount)

Thanks you very much in advance

1 Answer 1


well, you don't unlock the account created with option 2, because it's NOT locked to begin with. It returns an account object with the private key in plain sight, which can be used to sign transactions straight away. "Locking" means protecting a private key with a password. With the account private key unencrypted, it's already an "unlocked account", and you can just use the signTransaction function of the account object returned to sign and send a transaction.

  • Thank u very much for the comment . The reaseon for post is let's say I wont to use account two days after creation . how I can use it for signing transaction in that case ?is it possible without web3.eth.personal.unlockAccount ?
    – Albert
    Commented Mar 20, 2018 at 15:04
  • @Zara Danielyan, yes, as long as you have that returned account object (which contains the private key in plaintext), you can sign transactions with it. Actually as long as you keep that plaintext private key somewhere, you (and anyone who has access to it) can sign transactions any time you want. There's nothing to unlock since there's nothing locked to begin with. Albeit it's NOT a recommended practice since it's EXTREMELY unsafe to store the private key in plaintext.
    – hellopeach
    Commented Mar 21, 2018 at 5:49
  • Thanks )) I will go with second option , I understand risks , may be I wil use internal encryption system . But for most of the users this is the convenient way creating wallet , they don't want to store anything , that is why I want to keep track of private keys .
    – Albert
    Commented Mar 21, 2018 at 5:56

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.