1

I get this error when I deployed smart contract to my private chain.

Error: Node error: {"code":-32000,"message":"unknown account"}

This is my web3.js code.

 const bytecode = "0x608060405234801561001057600080fd5b506040516020806101018339810180604052602081101561003057600080fd5b8101908080519060200190929190505050806000819055505060aa806100576000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063c412eaba146037578063ca6158cb146053575b600080fd5b603d606f565b6040518082815260200191505060405180910390f35b60596078565b6040518082815260200191505060405180910390f35b60008054905090565b6000548156fea165627a7a7230582042b7071573f040950b28decc097069f3f208055692800cf2260019f40904af610029"
    var itemContract = new this.props.web3.eth.Contract([{"constant":true,"inputs":[],"name":"getItem","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"itemId","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"id","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]);

itemContract.deploy({
  data: bytecode,
  arguments:[1]
})
.send({
  from: decryptEtherAccount.address,
  gas: 0,
  gasPrice: '0',
}).on('error', (error) => {
    console.log("Error: ", error);
}).on('transactionHash', (transactionHash) => {
    console.log("TxHash: ", transactionHash);
}).on('receipt', (receipt) => {
  console.log("Address: ", receipt.contractAddress)
}).then((newContractInstance) => {
    console.log(newContractInstance);   
}).catch(function(error) {
    console.log(error);
});

Could you give me any advise why I am getting this error, please?

3
  • Either ecryptEtherAccount.address is an illegal address, or you haven't unlocked this account on the node that you're connected to. Commented Sep 28, 2019 at 6:45
  • @goodvibration I have made ether account from web3.eth.accounts.decrypt() function. I have tried unlock ether account, but it was not succeeded. Do you know any way to unlock account?
    – gnxvw
    Commented Sep 28, 2019 at 7:25
  • web3js.readthedocs.io/en/v1.2.1/… (this one is for web3 v1.2.1, so make sure to read the one corresponding to the web3 version that you're using). Commented Sep 28, 2019 at 7:49

1 Answer 1

0

In my case, I used private chain, so I could deploy it when I deploy from node address.

If you want to deploy from any other address, it is better to use sendTransaction to deploy contract.

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.