2

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
  console.log(value)
  value = helloworldcontract.getValue()
  console.log(value)

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

1

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}); 
1

I had this error message and resolved it by quitting testrpc and the powershell host that was running the truffle console. Restarted all and everything was fine again.

  • Thanks! I got this error with Embark because I didn't refresh my browser after changing my contract. I restarted my terminal commands are refreshed my browser page. – Justin Harris Aug 20 '17 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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