[Ethereum] Setting up private network w Geth, can’t unlock account and deploy contracts

accountsgo-ethereumtruffle

I have set up a private network with Geth with the following command:

geth –datadir="PathToDatadir" –mine -minerthreads 2 -verbosity 3 -maxpeers 5 –ipcapi "admin,debug,eth,miner,net,personal,shh,txpool,web3" –ipcpath "geth.ipc" –port 30301 –rpc –rpcport 8101 –rpcapi eth,web3,personal –etherbase "e04fe31f4133f25ef3e5bfb39146edcf28724acd" –networkid 9990

So far so good.

I have developed a system of contracts using truffle and testrpc and am now trying to deploy this to multiple nodes. When running truffle migrate, i run into trouble:

Running migration: 1_initial_migration.js
Replacing Migrations…
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: account is locked

I have configured truffle to send from an address I want (same one that is defined as etherbase) but the account is locked. There are multiple ways to unlock an account using Geth. The only way it seems to work for me is if I unlock the account like this:

geth –unlock "e04fe31f4133f25ef3e5bfb39146edcf28724acd" –password "fullPathtoTxtPasswordfile"

Does the account remain unlocked for future Geth invocations ? Unlocking through personal.unlockAccount("address","fullPathtoTxtPasswordfile") in the console is not working either. web3.accounts is also undefined.

So I seem to have succeeded in unlocking the accounts but truffle migrate is still giving me the account locked error. I have found similar problems with account unlocks but have not found a solution for my own specific problem.

Best Answer

personal.unlockAccount does not take a file path, it takes a password. See: https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console#personalunlockaccount

On the command line, try using this:

geth --unlock 0 --password "fullpathtofile" - the unlock argument takes an index. You can see the indexes by running geth account list.

If you want to make sure that it's not a problem with the file, you can also do this:

geth --unlock 0 --password <(echo "PASSWORD_HERE")

The <(command) form executes the command inside the parenthesis and creates a named pipe that it passes to the program, acting as a file with the contents of that output. You can use this as a test for non-sensitive test accounts.

Related Topic