The situation I have is this:
so I assume the difference of 2 comes from my 2 pending transactions?
I've only tested this on rinkeby.
To reproduce the error you'll need to submit a transaction that sits too long with a pending status.
I'm fortunate/unfortunate enough to be able to reproduce this consistently when trying to deploy a contract on rinkeby. (at the time of this writing, my contract deployments are taking up to two days to confirm regardless of gwei).
If you want to try and reproduce, here is my rough code and hopefully your transactions pend awhile ;)
// I've already compiled using solc and have the abi and bytecode
let contract = new web3.eth.Contract(abi);
let txn = contract.deploy({data: '0x'+bytecode});
let txn_object = {
gas: 270000,
gasPrice: '55',
from: from,
data: txn.encodeABI()
};
web3.eth.getTransactionCount(from)
.then(nonce => {
txn_object.nonce = nonce;
let raw_txn = new require('ethereum-tx')(txn_object);
raw_txn.sign(private_key);
let serialized = raw_txn.serialize();
let signed_txn = '0x'+serialized.toString('hex');
web3.eth.sendSignedTransaction(signed_txn).on('receipt', (result) => console.log(result));
})
running this the second time results in transaction already known error because getTransactionCount() is returning previous nonce.
I know that I could reproduce using txn.send({from:from}) instead of going through the trouble of manually signing the txn, but I wanted to report exactly what I'm doing.
I believe you can call web3.eth.getTransactionCount(address, 'pending') to include pending transactions.
@dostu Unfortunately no. That is another issue that remains open. You can read here
@abrinckm Same probleem here. I want to know how many number transaction is pending that created by me. Do you have a any solution for that?
@Bat-Orshikh If you enable the Txpool API by running geth with flags --rpcapi txpool
Then you can open the geth console (e.g., geth attach http://localhost:8545) and enter txpool.content
you should see details on a number of pending or queued transactions. I haven't figured out how to revert transactions at the moment. Although there is a "not a great" solution here: https://ethereum.stackexchange.com/questions/1774/geth-how-to-clear-queued-transactions
@abrinckm thanks for the reply.
I'm using infura. And I can't get the pending transaction number.
So I just handled my nonce problem.
When can we expect to be fixed? it's actually costing an important amount of effort just to handle the nonce issue.
Is this still an issue? As @abrinckm mentioned, this issue is related, but it's solved now. So if the node you use updated to the latest version of go-ethereum, than this issue is solved as well. Please correct me if I'm wrong.
@stukker01 Thanks for figuring this out! I'm closing this issue now and if someone still has this issue then please feel free to drop a comment here and tag me.
Any update on this? This is still an issue on Quorum v2.2.4 using web3 1.0.0-beta.55.
We're retrieving the nonce like this: eth.getTransactionCount(this.account.address, 'pending');. However, if we send a lot of transactions at the same time, some of them fail:
Transaction has been reverted by the EVM:
{
"blockHash": "0x004092e938498bbdc9ce609a854ab588a39cc69da54201b572f61873157684e2",
"blockNumber": 1769,
"contractAddress": null,
"cumulativeGasUsed": 29919,
"from": "0xeddf42a34b24d37bc6f4b8aac1d11eb8a72f99ae",
"gasUsed": 29919,
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": false,
"to": "0x353b7ffc2eaa9ca5d5a55b377956d201ef100645",
"transactionHash": "0x05d2611ce819bbeb3de934a0f9537c32dc78eb6559532725a39e6938930c77b8",
"transactionIndex": 0
}
This does not happen if we manually increment the nonce for each transaction.
This is still an issue. I've been able to reproduce the issue as @lucashenning described, but also it can happen when done slowly too. Such as between the time it takes to broadcast the transaction (I assume) and when a new transaction is being constructed. A workaround could be to have N addresses and only use an address if the last TX it constructed has been recognised by the network, or add iteration logic for the nonce yourself – I think web3 should be smart enough to track that a transaction is valid and has been attempted to be broadcast and should internally update it's nonce on the client-side.
This is mostly speculation here, but this issue is definitely NOT gone and is extremely frustrating since the result is your transaction just doesn't get broadcast or is rejected for having the same nonce.
@tsujp @nivida Hey Is the issue over? What is the solution for having correct nonce while sending a transaction.?
@tsujp @nivida Hey Is the issue over? What is the solution for having correct nonce while sending a transaction.?
I don't use Web3 anymore I use Ethers.js now and I also defer that stuff to Metamask as Ethers.js has some edge patch to fix this too which I haven't used yet. Concerning Web3, I believe it has some edge version, likely 2.0.0-alpha.1 or whatever the tag is called which has this fixed, sorry I cannot give you anymore at this time.
@abrinckm thanks for the reply.
I'm using infura. And I can't get the pending transaction number.
So I just handled my nonce problem.
Could you throw some light on this, @Bat-Orshikh! How exactly did you solve the nonce issue?
Most helpful comment
I believe you can call
web3.eth.getTransactionCount(address, 'pending')to include pending transactions.