4

I have this code, which works:

MyToken.airdrop(wallets,amounts,{
  gas: 1267051,
  gasPrice: 2000000000,
},function(err,tx){
  console.log('err is %s',err)
  console.log('tx is %s',tx)
  callback(err,tx)
})

Now Let's say I want to control the nonce myself (reason here) so I do:

MyToken.airdrop(wallets,amounts,{
  gas: 1267051,
  gasPrice: 2000000000,
  nonce: 432 // = web3.eth.getTransactionCount() + 1
},function(err,tx){
  console.log('err is %s',err)
  console.log('tx is %s',tx)
  callback(err,tx)
})

I get a tx hash as output, not an error, yet the transaction can't be found on the appropriate etherscan, it seems to never get sent to the network. Tried on Rinkeby, Ropsten, and Kovan.

What could be the problem with specifying nonce myself or the way I'm doing it?

Note: I'm using infura as the "node".

shaharsol
  • 561
  • 1
  • 5
  • 15

1 Answers1

9

Apparently there's a nuance with the nonce... my error was I was setting the nonce to web3.eth.getTransactionCount() + 1, which left a gap between prior transaction nonce and next transaction nonce (nonces are 0 indexed, transactions are indexed from 1, that's the root of the error). It so appears that you are not allowed to increment the nonce by 2 and leave a gap. Must be sequential.

Vignesh Karthikeyan
  • 1,950
  • 1
  • 12
  • 40
shaharsol
  • 561
  • 1
  • 5
  • 15