4

I am new to this technology and I am trying to Deploy the contract to Ropsten test network. I have my geth running in one terminal. In my truffle console I have an account with some ether. I unlock it, then straight after in another terminal I go to my project directory to run truffle compile, then truffle migrate.

I get this error:

Running migration: 1_initial_migration.js
  Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: account is locked
    at Object.module.exports.InvalidResponse (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/errors.js:35:16)
    at /usr/local/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/requestmanager.js:86:36
    at null.request.onreadystatechange (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:114:13)
    at null.dispatchEvent (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at doNTCallback2 (node.js:450:9)
    at process._tickDomainCallback (node.js:405:17)

I have changed my gas to different amounts but rolled it back, since that seems to not be the problem as I have enough ether.

I also googled the problem and it suggested I get the latest geth, I believe i do.

Can someone please help? I am totally new to this and completely lost and don't know what else to do. Perhaps I should use embark.

I appreciate any advice :) thank you beforehand

Namu Ujin Na
  • 111
  • 2
  • 4

1 Answers1

5

Truffle is a great framework. I wouldn't steer you away from it. In my experience, this error is not misleading. I don't think the account is unlocked the way you think it is.

In geth, when you do:

web3.personal.unlockAccount("address")

it doesn't last very long at all. 30 seconds if memory serves. In any case, this might help:

web3.personal.unlockAccount(web3.personal.listAccounts[0], "password", 15000)
  • whatever address is first
  • put the password in the 2nd argument
  • unlock it for 15,000 seconds (so it won't bother you for a while).

Should respond true.

Hope I didn't flub the syntax. Just a handy phrase to know.

Hope it helps.

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145
  • Hi Rob, thank you for the quick response. I have tried the second command but i get this error: Error: could not decrypt key with given passphrase at Object.module.exports.InvalidResponse (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16) at null.RequestManager.send (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/requestmanager.js:61:22) at Personal.send [as unlockAccount] (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/method.js:145:58) at evalmachine.:1:-47 @RobHitchens – Namu Ujin Na Feb 03 '17 at 22:45
  • 1
    Password error. Also probably not misleading. Put your real password in there where I said "password". You can also do web3.personal.listAccounts to confirm that you have accounts on this network. You need at least one. – Rob Hitchens Feb 03 '17 at 22:53
  • yes I have entered my correct password. and I have 3 accounts :( the only time it returns true is when it is truffle(default)> web3.personal.unlockAccount('address', 'password', 15000), but then in the other console when i try to deploy it by running truffle migrate, its complains that the account is locked, bear in mind i am doing it as fast as possible, cannot be longer than 30 secs :/ @RobHitchens – Namu Ujin Na Feb 03 '17 at 23:16
  • I just realized this issue isn't new. Have a look here: http://ethereum.stackexchange.com/questions/10160/truffle-migrations-account-locked-error-with-network-command and check your geth command line (rpc stuff) and truffle.js. – Rob Hitchens Feb 03 '17 at 23:23
  • yes this is a similar problem, but there is no fix... i was hope me posting would help @RobHitchens – Namu Ujin Na Feb 03 '17 at 23:27
  • I remain focused on the account locked, but it's hard to pinpoint exactly what's wrong. Couple thoughts. Can you confirm you're using truffle 2 and not the truffle 3 that came out this week? Second, a workaround. I would suggest testrpc. It's better for development (mines instantly) and also simpler to set up. In this case, taking testnet out of the picture might narrow down the search area for the actual issue. Starting testrpc with $ testrpc -u 0 -u 1 will give you two unlocked accounts with test ether. Plays nice with truffle. Also, post truffle.js in your question. Might reveal something. – Rob Hitchens Feb 03 '17 at 23:55
  • Hi Rob, I have degraded to truffle 2.0.0 and redid everything. I still get the account is locked. I do not understand why...i think i may use embark. @RobHitchens – Namu Ujin Na Feb 05 '17 at 23:54
  • Hi Rob, I am trying to use testrpc. Does it work the same way? As In i need to unlock the account in truffle console then run truffle migrate in another console? @RobHitchens – Namu Ujin Na Feb 06 '17 at 02:07
  • Starting testrpc with $ testrpc -u 0 -u 1 will give you two unlocked accounts with test ether. 8 more that will be locked. Will listen for rpc on 8545. It's a blockchain simulation of sorts. Very fast. – Rob Hitchens Feb 06 '17 at 02:33
  • Hi Rob, thanks so much, i shall just use testrpc then. :) I hope u have a lovely day @RobHitchens – Namu Ujin Na Feb 07 '17 at 00:34
  • actually truffle is a terrible framework and you should not use it outside of development – Nico Vergauwen Oct 16 '18 at 11:39