2

Title is self-explanatory. It is my understanding that the way blocks are mined, the miner takes a snapshot of a collection o transactions at time T and starts solving the puzzle. But what happens if I cancel my transaction at T+1sec? Will the snapshot of the miner be updated to exclude my transaction? If not, wouldn't that mean that my transaction would still be mined even if it was cancelled?

Thanks

Hiperfly
  • 459
  • 4
  • 11

1 Answers1

1

Cancelling a transaction means replacing a pending transaction with another one that has the same nonce, but a higher gas price.

You can never be sure which transaction will be mined and there is never a guarantee that your first transaction will be cancelled.

Miners are free to include in a block whichever valid transaction that they want. Normally, they prefer transactions with higher gas price (your replacement transaction), but they could chose to process the one with the lower gas price instead (your original transaction). Also, your second transaction may arrive after the miner has built the block it is currently mining and he may not have time to rebuild it with your replacement transaction before the block is mined.

However, you can be sure that only one of the transactions will be mined and never both. Only one transaction for a given nonce and address can be validly mined.

Undead8
  • 3,570
  • 9
  • 28