1

Error: could not unlock signer account

Using web wallet to manage accounts in browser. But getting the above error when calling a function of a smart contract. This happen after updating the web provider with a different keystore.

Updating the Web3 Provider:

// Hack to provide backwards compatibility for Truffle, which uses web3js 0.20.x
Web3.providers.HttpProvider.prototype.sendAsync = 
    Web3.providers.HttpProvider.prototype.send;

var web3Provider = new HookedWeb3Provider({
   host: "https://mainnet.infura.io/[TOKEN]",
  transaction_signer: keystore
});

this.web3.setProvider(web3Provider); //Will overide MetaMask Injected Provider!

Calling some method:

  await deployedDApp.someFunction(
    param1, param2, param3, 0
    , { from: web_wallet_account, gas: 1000000 }
  );

Note: I do not want to unlock the account on the node. I just want to use a keystore that is generated in the web using eth-lightwallet. However, web3._provider.transaction_signer is already set well and have the address of my web wallet account.

1 Answer 1

1

The Provider is needed to set at contract-level (for each contract). At initialization time, and every time, you update the Web3 provider. You need to update it for all contracts that you are using:

So, in case of updating the web provider as following example:

var web3Provider = new HookedWeb3Provider({
  host: "https://mainnet.infura.io/[Token]",
  transaction_signer: keystore
});

this.web3.setProvider(web3Provider);

This then has to be repeated for every contract.

contractAbstraction.setProvider(web3.currentProvider);

Your Answer

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

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