When web3.eth.accounts.create is used to create an account something like this can be seen.

> {
    address: "0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01",
    privateKey: "0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709",
    signTransaction: function(tx){...},
    sign: function(data){...},
    encrypt: function(password){...}

now if web3.eth.accounts.encrypt(privateKey, password); is executed using the same privatekey that we got from the previous step we can get a output as the web3 keystore v3 standard. Now if we store this file in the geth node's keystore folder (ex user/.ethereum/private/keystore) and run personal.listAccounts we can get our created address on that list.

So when I need to unlock this account with web3.personal.unlockAccount what would be the passphrase that I need to give to unlock my account?

2 Answers 2


web3.eth.accounts.create(); already creates a new account

You can look the new account info using something like this in js:

var account = web3.eth.accounts.create(); //Creates the account (is an object) console.log(account); //show the object in the console

Then, if you want to get the keystore you have to provide the privateKey and a password using something like this:

var walletprivate = account["privateKey"]; //Get the private key from the object var phppasswallet = "THE_PASSWORD"; //provide a password var keystore = web3.eth.accounts.encrypt(walletprivate, phppasswallet); //Get the keystore

But this is just if you want the keystore for the account; with the web3.eth.accounts.create(); the account is already created and you can use it directly with the private key


It's the password used in the encrypt function.

What you do here is, store the private key of your account encrypted(so no one can find it by just accessing the keystore files) using the password.

In order to unlock the account you need to get the private key bck by decrypting it. There you need to provide the password used for encryption.

  • personal.unlockAccount only accepts address and passphrase so how can I unlock that created account which was encrypted by my encryption passphrase. Sep 22, 2017 at 4:22
  • does web3.eth.accounts.create() actually create a new account? If it use it with testrpc I can't see a new account.
    – Bumblebee
    Nov 4, 2017 at 10:39
  • I'm getting web3.eth.accounts.create is not a function. How do you resolve this?
    – zero_cool
    Apr 5, 2018 at 19:22
  • web3.eth.accounts.create() was introduced in web3 1.0. you should be using a earlier version. check your web3 version Apr 6, 2018 at 0:51

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.