2

I want to send a transaction using web3, and I want this transaction to have the same nonce as other transactions - so far so good. The issue comes when I set a lower gasPrice than the other transactions. When I do this, I get an error:

Replacement transaction underpriced

I am aware that the transaction is underpriced compared to the existing ones, but still I want it to issue the transaction instead of throwing an error and messing up the whole program.

Is there a way to circumvent this? Should I use any other API for this purpose? or am I doomed to always be the highest bidder?

Thanks

3

It doesn't make any sense to send the same transaction with lower gasPrice: If both transactions are in mempool, the miners pick the transaction with the higher gasPrice (your first transaction), so there's no need to add the second one.

If, for whatever reasons, you really want to have the same transaction with lower gasPrice, you could do the following:

  • cancel the pending transaction - this costs gas, because it actually sends a 0 ETH transaction to itself, with a higher gasPrice than the original tx
  • re-submit the original tx (with its nonce increased ), with a lower gasPrice

I can't imagine any scenario where this would be of any help, but it's definitely possible.

  • Thank you for your wisdom. Believe it or not this case exists. – Victor Feb 13 '18 at 16:49
  • cool. I'm glad my answer helped you – Tudor Constantin Feb 13 '18 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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