Hash returned but not broadcasting
We are receiving a hash back from sendRawTransaction but the transaction is never broadcasting to the network or if it does it could take 24 hours. Is this normal? Should we be getting a hash back if it has not broadcasted yet?
nonce++;
var nonceHex = web3.toHex(nonce);
var valueAmount = web3.toHex(amounts[i] * tokenMultiplier);
data = contract.transfer.getData(addresses[i], valueAmount, {from: "0xd5c..."})
var rawTx = {
"from": "0xd5c...",
"nonce": nonceHex,
"gasPrice": gasPrice,
"gasLimit": gasLimit,
"to": contract.address,
"value": "0x00",
"data": data,
"chainId": 0x01
}
var tx = new Tx(rawTx);
tx.sign(privateKey);
var serializedTx = tx.serialize();
web3.eth.sendRawTransaction(`0x${serializedTx.toString('hex')}`, function (err, hash) {
if (err)
console.log(err);
else
console.log('Transaction hash: ' + hash);
});
Thanks
Check if your nonce is too high?
I have checked that and its correct. We also started with a new wallet to see if that would help so the nonce would start at the beginning and that did not work either. Its been 17 hours and it has not broadcasted yet.
This is happening to me as well.
This is happening to me as well.
This is happening to me as well. :(
@kilmas & @i-am-vivek could you provide a code example too?
I can add some additional information.
When I first started working with Web3.js I was ignorant to a lot of how Ethereum transactions worked. What was happening was my transaction was being broadcast but the node I was broadcasting to was not adding the transaction in the transaction pool. This can happen for a number of reasons:
- Transaction pool of the node is full and the gas price is too small to take a spot in the pool
- Node is handling too many transactions and one gets dropped
- Other consequences of the non-deterministic nature of the Ethereum network.
In summary, none of these is caused by a bug with Web3.js.
My solution was writing a more robust version of what I was trying to accomplish and to monitor gas prices closely so that my transactions were not under gassed.
I'm not ruling out a possible bug with Web3.js, but because the three things I listed above are much more likely to be the cause of this occurring, I think @nivida would need a very detailed example to even start working on this.
@cj-zeiger Thanks!
Hey, I don't know whether the problem was with my node which I had installed or web3. later I moved to ethers.js and got a free node from infura.io. And configured in ethers.js. it started working.
@i-am-vivek It was a problem of the node. Hopefully, you're coming back to the Web3.js library ;) We have some cool new features like customizing of the transaction signing process, correct transaction confirmations, Realms implementation, Web3 Module API and way more. Check our documentation to get more details about :)