I'm running an airdrop script which essentially loops a database of recipients and invokes a batchTransfer
function each time with 80 different recipients and amounts.
After about 10 successful submissions, each new submission is rejected with "replacement transaction underpriced" – though the data of the request is different!
The stack is web3
|infura
|rinkeby
I read the answer here but not sure it applies. Will changing the nonce solve it? Where do I do it anyway? is nonce a param I add to the json array along with gas
and gasPrice
? And anyway, why doesn't the network see the data is different in each transaction I try to submit?
Best Answer
You can indeed change the
nonce
by hand; it is a transaction parameter and it goes alongsidegas
,gasPrice
,value
.So your script can simply increment it then fire and forget the transaction.
Now, you need to find out the nonce value of the first transaction you fire. Easy:
var firstNonce = web3.eth.getTransactionCount(yourSender);
.Edit:
Infura servers are at different states, so if your script calls
web3.eth.getTransactionCount
behind the scenes, it will get different results. Your script needs to keep track of the incrementing nonce and only callgetTransactionCount
once.