0

Let's say, I send a transaction, all of my Ether, with low gas fees and it'll take hours for it to complete. Right away I send another one, from the same wallet or address, also all of my Ether, to some other address and with a high gas fee so that it'll complete in a minute.

Is this called double spend or what?What'll happen to my 1st transcaction when the time has come and it's being processed by miners or validators? How will it be resolved?

0

high gas fee so that it'll complete in a minute

It won't.

What'll happen to my 1st transaction

It's still first.

This is one of the subtleties to get acquainted with. Transactions from different accounts mine in indeterminant order decided by the miners. However, transactions from the same account are guaranteed to mine in nonce order. A side-effect of this is that not only does the first transaction take a long time to mine, it also jams up the queue and everything that came after from the sender's account.

There is a method of cancellation which is, in summary, to send another transaction with higher gas and the same nonce as the transaction to kill. This will unjam the account. A "do nothing" or "do the same thing" structure is usually appropriate.

Is this called double spend or what?

No.

Double-spend is any scenario that allows you to send funds, receive consideration and re-use the funds that were already sent. Your scenario does not create that. However, if you tricked your friend with the pending transaction (that everyone can see) and they were naive enough to accept it as just as good as confirmed then maybe you could receive something and then get the money back by canceling the underpriced transaction with the method described above.

A buggy contract could allow such a thing to happen. A man-in-the-middle attack on an exchange could, in theory, cause them to send something thinking they have funds they do not actually have because someone is pretending to be the blockchain. In practice, that would be very hard to simulate for an appreciable length of time but the possibility offers a hint at one of the reasons they wait for several confirmations before recognizing deposits.

Hope it helps.

10
  • It won't. - it will – DoctorDoom338 Jan 20 at 10:15
  • However, transactions from the same account are guaranteed to mine in nonce order. - yes, and so what? How does it answer my question? "nonce" can be set manually and therefore my 2nd transcaction could appear as a 1st one in a pool – DoctorDoom338 Jan 20 at 10:17
  • If you've manually set the nonce of the second transaction to that of the first, then yes, the first transaction gets "out-gassed". Once the second transaction is mined into a block, the first transaction - now with an already-used nonce - gets dropped as invalid. – Richard Horrocks Jan 20 at 10:45
  • I meant a different thing.However, transactions from the same account are guaranteed to mine in nonce order. -- what if I sent a 2nd transaction with a lower nonce but with higher gas fees? 2nd transction would get mined in several minutes. But in, say, 5 hours the time for the 1st would come. What happens when a miner begins to process the 1st tx and discovers that all ETH from my address has already been spent? – DoctorDoom338 Jan 20 at 20:52
  • 1
    "If I sent a 2nd transaction with a lower nonce" - if it is the next unmined nonce then it gets mined next. If another transaction with that nonce is already mined then it fails. "what the that?" The transaction replacement process. Two pending/unmined transactions that have the same nonce are in a race. Usually the one with the higher gas fee will be selected. Whichever one mines first invalidates the other. The nonce is a sequence number and the protocol guarantees an unbroken, exclusive, sequential confirmation order. – Rob Hitchens Jan 22 at 0:35

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.