15

I have started a private blockchain using the command,

geth --networkid 1337 --datadir ~/home/xyz/testnet --ipcpath /home/xyz/.ethereum/geth.ipc --rpc --rpcapi eth,web3 --rpcport 8545 --rpcaddr localhost --rpccorsdomain "*";

Next, in another terminal console, I start the miner and unlock my test account,

> miner.start(1)
true


> personal.unlockAccount(web3.eth.coinbase)
  Unlock account 0xSomeAddress
  Passphrase: 
  true

My truffle.js file contains the following,

module.exports = {
build: {
  "index.html": "index.html",
   "app.js": [
     "javascripts/app.js"
   ],
  "app.css": [
    "stylesheets/app.css"
   ],
  "images/": "images/"
},
networks: {
"staging": {
  network_id: 1337, 
  from: "0xAddress" // Unlocked Address
 }
},
rpc: {
  host: "localhost",
  port: 8545
 }
};

Finally, in another terminal, I run and compile the truffle application using,

truffle compile
truffle migrate --network staging

I get the below Account locked Error like below,

Running migration: 1_initial_migration.js
  Deploying Migrations...
  Migrations: 0xSomeAddress
Saving successful migration to network...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: account is locked
   at Object.InvalidResponse (/usr/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/errors.js:35:16)
   at /usr/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/requestmanager.js:86:36
   at request.onreadystatechange (/usr/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:114:13)
   at dispatchEvent (/usr/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
   at setState (/usr/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
   at IncomingMessage.<anonymous> (/usr/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
   at emitNone (events.js:91:20)
   at IncomingMessage.emit (events.js:185:7)
   at endReadableNT (_stream_readable.js:974:12)
   at _combinedTickCallback (internal/process/next_tick.js:74:11)
   at process._tickDomainCallback (internal/process/next_tick.js:122:9)

Which part am I missing here? Is the process that I followed correct? The same code runs sublimely on testrpc but not on this private blockchain, what essential part am I missing?

Please advice.

2
  • Please confirm . You ran the geth command in one terminal and unlocked account in another.
    – Aniket
    Nov 22, 2016 at 7:25
  • @A.K. Yes. I did unlock the account in another Terminal.
    – godimedia
    Nov 23, 2016 at 19:27

2 Answers 2

10

Possible it's not unlocked long enough?

web3.personal.unlockAccount(web3.personal.listAccounts[0],"password",15000); // 1st account, pw & time in seconds ...
3

I was having the same issue but you may try to check the state of your account using geth itself, it did the trick for me.

When you are syncing/acting on the blockchain, geth uses a file for the Inter-process communication (IPC). Check what is that file on your case, something like:

INFO [10-02|17:49:23] IPC endpoint opened: /Users/josealves/Library/Ethereum/testnet/geth.ipc

You can then "attach" geth to this by typing:

geth attach /Users/josealves/Library/Ethereum/testnet/geth.ipc

You would then have a prompt where you can send commands to the blockchain and interact with the current session. By typing the personal command you can find the current state of your "wallet" of accounts:

{
  listAccounts: ["0xcb7fab56b707a54d17c791de41eaa9a399b3efef", "0x3a05b7c9f420f6b7c5f39ae29deab1352750bf26"],
  listWallets: [{
      accounts: [{...}],
      status: "Locked",
      url: (..)
  }, {
      accounts: [{...}],
      status: "Locked",
      url: (...)
  }],

There you'll get the current state of your account, and probably both of them are on the "Locked" state. You can then unlock them by typing:

personal.unlockAccount('0x3a05b7c9f420f6b7c5f39ae29deab1352750bf26')

You will then be asked for your account's password and it will be unlocked.

Afterwards it was ok to migrate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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