I am trying to run my first contract, but I am getting this error when using my dev testnet account.

Error: authentication needed: password or unlock undefined

I am using geth to run JS console using this command

geth attach

What should I do to use authenticate my account?

Thanks in advance!

1 Answer 1


You can unlock the account using below command on geth console:

If you have not created more than one account on geth then use -

personal.unlockAccount(eth.coinbase, 'your account password in quotes', 0)

The first argument in above command is the account hash(address), second is the password in quotes and third is the time in seconds till the time you want the account to be unlocked.

eth.coinbase is default account which gets created while initializing genesis block. You can also use eth.accounts[0] in place of eth.coinbase

If the account you are trying to unlock is not the first one then use the index of your account from this array - eth.accounts.

For instance, if my account is at second index then you can use it like this -

personal.unlockAccount(eth.accounts[1], 'your account password in quotes', 0)

Hope this helps.

  • 1
    Helped very much. Worked great.
    – james-see
    Jul 23, 2018 at 15:08

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.