[英]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.