1

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)
console.log(address)

Are there any problems of my code?

Also, could we unlock account, not node?

7
  • Have you tried what I suggested to you in a comment on your previous question? Commented Sep 28, 2019 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
    Commented Sep 28, 2019 at 11:40
  • Yes, you did... Commented Sep 28, 2019 at 11:53
  • @goodvibration Sorry, where is it ...?
    – gnxvw
    Commented Sep 28, 2019 at 12:25
  • It's in I think I don't need to unlock account. Commented Sep 28, 2019 at 13:02

1 Answer 1

0

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 and acknowledge you have read our privacy policy.

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