0

I'm building an ETH wallet as an exercise to learn more about the Etheruem blockchain. I was wondering what mechanism is used to decide which transaction is executed first.

Suppose the following:

  • 2 transactions are sent to the same smart contract at the same time
  • Transaction are sent from 2 different accounts
  • Transactions have same gas amount
  • Both transactions are sent to the Infura node

What decides which one of these two transactions get broadcasted from the mempool of the node first? Further, is the transaction that was broadcasted first going to be included in the next block earlier and considered final always?

1 Answer 1

0

the txs ordering is depended on the node implementation(mining clients) and the miner of the block. some implementation will handle mempool txs differently than others, and this can further be configured individually by a miner.

if the miner wants, she can include a txs with 0gas even, however this doesn't usually happen as most mining clients will optimize for profit (highest gasPrice). In the case of two transactions with identical profit, the client will likely choose the transaction that was broadcast first.

for more details you used check out this PR regarding making changes to the geth client txs sorting for same gas price txs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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