2

I'll use the DApp, CryptoKitties as an example:

Let's say some sweet digital cat is released with a "buy now" button for 1 Ethereum and 3 people make the transaction via MetaMask. All 3 transactions start pending.

  • Person A sends the transaction at 09:04:01 with gas price of 2 Gwei
  • Person B sends the transaction at 09:04:21 with gas price of 20 Gwei
  • Person C sends the transaction at 09:04:51 with gas price of 100 Gwei

If Person A's transaction takes 5 minutes to be verified, Person B's takes 40 seconds, and Person C's takes 10 seconds, then:

  • Whose transaction gets priority and is added to the block? (Only one will go through while the others are refunded minus the gas for the computation)

  • Does the timestamp of the initiated transaction have any effect on priority?

A detailed/technical answer would be very much appreciated. Thanks!

  • You do not provide any information why only one transaction will be successful and not the others. They all send 1 ether? They will all be processed. – Florian Castelain Jan 26 '18 at 10:08
  • Only one transaction will be successful because the kitten can only belong to 1 person. Yes they will all start processing, but only 1 will be successfully added to the block, while the other 2 will fail and get a refund. – Russell Kranz Jan 26 '18 at 10:22
3

Whose transaction gets priority and is added to the block? (Only one will go through while the others are refunded minus the gas for the computation)

Whichever of the 3 transactions was chosen by the miner who finds the block. Miners can pick any transactions they like, so long as they allow for valid state changes. (They can do this by writing their own mining code, or adjusting the vanilla client code to suit their needs.)

For those miners running the Geth client, they will pick transactions based on price and nonce, highest price first. See this previous answer for a detailed explanation: What is the default ordering of transactions during mining, in e.g. geth? (The same most likely holds true for the Parity client, though I haven't looked at the code.)

Does the timestamp of the initiated transaction have any effect on priority?

No. If they're all in the transaction pool at the same time, then the ordering I mentioned above will hold. (There's nothing in the vanilla client code that takes timestamp into account.)

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.