简体   繁体   中英

Error: Returned error: invalid sender, Ethereum private network error

Hi, i was trying to deploy a smart contract from a lambda function unfortunatly i'm fetting the following error on sendSignedTransaction() function, can someone tell me whats wrong here ?.

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)

This is most commonly an issue with the chainId . Ensure that you have correctly declared the chainId within the config section of your genesis.json file as follows:

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

Also, be sure that await web3.eth.net.getId() is returning the correct value that matches what you have have configured.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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