I cannot unlock my account.

I decrypted my account from encrypted accoun, and want to unlock it to deploy contract.

However, I am getting this error,

 Node error: {"code":-32000,"message":"could not decrypt key with given passphrase"

This is my web3 code.

const decryptEtherAccount = await web3.eth.accounts.decrypt(etherAccount,'test!')
web3.eth.defaultAccount = await decryptEtherAccount.address
const account = await web3.eth.getAccounts()
const address = await web3.eth.personal.unlockAccount(account[0], decryptEtherAccount.privateKey, 1000)

Are there any problems of my code?

Also, could we unlock account, not node?

  • Have you tried what I suggested to you in a comment on your previous question? – goodvibration Sep 28 '19 at 10:44
  • @goodvibration Yes!! This code is what I did based on documentation. However, I didn't make my account by this function web3.eth.personal.newAccount(password, [callback]) , so I think I don't need to unlock account. Did I made mistake ? – gnxvw Sep 28 '19 at 11:40
  • Yes, you did... – goodvibration Sep 28 '19 at 11:53
  • @goodvibration Sorry, where is it ...? – gnxvw Sep 28 '19 at 12:25
  • It's in I think I don't need to unlock account. – goodvibration Sep 28 '19 at 13:02

We can unlock account only for the account that made from web3.eth.personal.newAccount(password, [callback].

If your address is made by in any other way, you don't have to unlock it.

You need your privatekey.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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