在向rinkeby发送原始事务以部署合同时,获取事务哈希,但在rinkeby etherscan.io中,它将txHash显示为无效字符串。这是我的代码:
web3.eth.getTransactionCount(account1, (err, txCount)=>{
//build the transaction
const txObject = {
nonce: web3.utils.toHex(txCount),
gasLimit: web3.utils.toHex(1000000),
gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
data: data
}
//Sign the transaction
const tx = new Tx(txObject)
tx.sign(privateKey1)
const serializedTransaction = tx.serialize()
const raw = '0x' + serializedTransaction.toString('hex')
//Broadcast the transaction
web3.eth.sendSignedTransaction(raw, (err, txHash)=> {
console.log('err:', err, 'txHash:', txHash)
})
})发布于 2018-09-21 05:48:39
在我的智能契约中出现了一个错误,因为它没有被部署,并且给出了无效的事务哈希。现在,当我更正错误时,我能够部署契约。
发布于 2018-09-21 07:37:22
如果您部署了一个新合同,txObject应该添加"from: address“。https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html?highlight=deploy
https://ethereum.stackexchange.com/questions/59121
复制相似问题