4

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?

1
  • I've had the same issue. It is Infura being a load balancer for a lot of nodes is causing this. Unfortunately, I could not find a way around it and ran them sequentially (all 2000tx I had to make) Jul 2, 2018 at 14:44

2 Answers 2

6

You can indeed change the nonce by hand; it is a transaction parameter and it goes alongside gas, 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 call getTransactionCount once.

4
  • I now realise the nonce is the way to overwrite existing transactions and the data is not checked at all? Why do I get transactions submitted with an existing nonce in the first place? Ah, is this what the infura load balancing problem about? They invoke the getTransacrionCount each time on a different node and get a different response each time?
    – shaharsol
    Jul 2, 2018 at 19:48
  • 1
    Yes, correct, Infura's servers have different states. That's why your script must keep track of the latest nonce sent and call getTransactionCount only once. Jul 3, 2018 at 8:45
  • Now that I've added nonce to the json I send along with the contract invocation, I get a tx hash, but when I look it up on etherscan it's not found. I tried on rinkeby, ropsten and kovan, so I believe its systematic. What can I be doing wrong?
    – shaharsol
    Jul 3, 2018 at 12:06
  • started it as a new question: ethereum.stackexchange.com/questions/52581/… I really want to mark this one as correct but must see I can control the nonce...
    – shaharsol
    Jul 3, 2018 at 13:16
0

set the following gas limit and gas price:- //gas limit

public static final BigInteger GAS_LIMIT = BigInteger.valueOf(4_300_000);

             //gas price

public static final BigInteger GAS_PRICE = BigInteger.valueOf(22_000_000_000L);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.