[Ethereum] Contract Call Web3 Error could not unlock signer account


I am using react for interacting with my HelloWorld Smart Contract:

var ETHEREUM_CLIENT = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
var helloworldcontractABI = <the json string>

var hellowordlcontractAddress = '0xffe299f7b09f53d716a0898b4454b3c53fb5c2e1'
var helloworldcontract =  ETHEREUM_CLIENT.eth.contract(helloworldcontractABI).at(hellowordlcontractAddress)

In my contract i have a method getValue – which returns an integer

When i call the following lines i get some errors:

  var value
  value = helloworldcontract.getValue()

Uncaught Error: Error: could not unlock signer account

What is here the problem? When i try the same scenario in truffle it works fine – so the contract is ok

Best Answer

So many deployment/test scenarios. This should help you poke at it. Specify the from account and make sure it's unlocked.

I usually start testRPC with

$ testrpc -u 0 -u 1 

to unlock the first two accounts. Or in geth/javascript

var account = web3.personal.listAccounts[0];
web3.personal.unlockAccount(account,"password",15000); // unlock for a long time

Then this should work:

var account = web3.personal.listAccounts[0];
helloworldcontract.getValue({from: account}); 

Takes the guesswork out of what's going on.

Or, since this is a getter that won't make a state change, add "call" for local execution that doesn't need gas.

helloworldcontract.getValue.call({from: account});