繁体   English   中英

错误:返回的错误:无效的发送者,以太坊专用网络错误

[英]Error: Returned error: invalid sender, Ethereum private network error

嗨,我试图从lambda函数部署智能合约,很不幸,我在sendSignedTransaction()函数上感到以下错误,有人可以告诉我这里有什么问题吗?。

Error: Returned error: invalid sender

  var blockchain = process.env.BLOCKCHAIN_HOST

  var web3 = new Web3(new Web3.providers.HttpProvider('http://' + blockchain + ':8545'))

  // Get the Bytecode
  var byteCode = compiledCode.contracts[':auction'].bytecode

  const contractOwner = '0x34db0A1FDGDCCDDDDXCX191e703Bf0182E0baE3'
  const privateKey = '0x403cf58c6a36eee43ac8467bec2c9d6546454461debffb4acff277548ef3'

  const tx = {
    chainId: await web3.eth.net.getId(),
    nonce: await web3.utils.toHex(await web3.eth.getTransactionCount(contractOwner)),
    gas: 4612388,
    from: contractOwner,
    data: byteCode
  }

  console.log(tx)

  const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey)
  const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction)

  console.log(receipt.contractAddress)

这通常是chainId的问题。 确保已正确声明的chainId的内部config的部分genesis.json文件,如下所示:

"config": {
    "chainId": 15,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
}

另外,请确保await web3.eth.net.getId()返回与您已配置的值匹配的正确值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM