簡體   English   中英

部署智能合約時出現節點錯誤 - Web3.js

[英]Node error when I deployed smart contract - Web3.js

當我將智能合約部署到我的私有鏈時出現此錯誤。

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

這是我的 web3.js 代碼。

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

你能給我任何建議,為什么我會收到這個錯誤,好嗎?

在使用地址發送交易之前,請確保您已將其添加到您的 web3 錢包中。

指南: https://web3js.readthedocs.io/en/v1.2.0/web3-eth-accounts.html#wallet-add

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM