How long does it take for a transaction to be included in a block? What impacts this? And what if your transaction gets ‘stuck’?

How long does it take for a transaction to be included in a block? What impacts this? And what if your transaction gets ‘stuck’?

On Ethereum there’s a new block every 12 seconds and on Bitcoin there’s a new block approximately every 10 mins. However this doesn’t mean that your transaction is guaranteed to be processed whenever this next batch of transactions is created.

This is because after your transaction is created (by the wallet you’re using, exchange you’re sending from or crypto product you’re exploring) it must be broadcast to the wider network and then sits within a mempool - a waiting room for transactions before they’re processed.

However generally the mempool has more transactions than space in the next block and so miners/validators on the chain must select which of these transactions to include and which stay behind hoping to be selected for the subsequent block. The criteria for selection is based on who’s willing to pay the highest transaction fee for the space they take up in the block (represented as sat per vBytes in Bitcoin and gwei in Ethereum - although n.b since EIP-1559, the base fee is burned and only the priority fee goes to the validator) and so as there is more pending activity on the chain, the transaction fee will increase as block space is more competitive.?

Currently there’s around 180,000 unconfirmed transactions in the Bitcoin mempool and around 160,000 on Ethereum.?


https://www.blockchain.com/explorer/charts/mempool-count
https://test.jochen-hoenicke.de/queue/#ETH,3m,weight


With the average bitcoin block holding c4,500 transactions (N.b this is up dramatically from c2,500 back in April 2023 due to growing use of SegWit and transaction batching from exchanges) and the average Ethereum block including c200, it’s clear that there’s more transaction than space available.?

The spikes seen above on the ETH mempool chart were driven by MEV, private order flow driven transactions and layer 2 activity. This drove prices to around $23 per transaction however previous chain congestion has seen MUCH higher transaction fees on Ethereum (I once paid $100 in fees so that I could buy my Aavegotchi a rare pirate hat).?

On Bitcoin in Jan/Feb this year, Ordinals mania still gripped the chain and so much of the mempool traffic was due to this inscribing activity. This pushed up transaction fees on the chain to around $24 per transaction as block space became a premium commodity.?

https://www.blockchain.com/explorer/charts/mempool-size
https://dune.com/data_always/ordinals

Linked to this, transaction fees spiked to an enormous $128 per transaction on the day of the 2024 halving (where the amount of bitcoin mined per block dropped from 6.25 BTC to 3.125 BTC) due to competition to inscribe the sats of this historic block, and fees hit $83 in June after power disruption impacted miners and BRC-20 tokens hype.?

https://bitinfocharts.com/comparison/bitcoin-transactionfees.html#3y

Ordinals and BRC-20 token activity back in October 2023 led to a spike in the average confirmation time rising from the usual c100mins to 25,800 minutes!?

https://www.blockchain.com/explorer/charts/avg-confirmation-time

So what can you do if your transaction gets stuck in the mempool and no miner/validator will pick it up yet?

On Bitcoin there’s a mechanism called ‘Replace By Fee’ (RBF) which is essentially where you create a duplicate of your existing transaction (technically the tx must include just one of the same inputs), and include a higher fee rate. Miners will then see both transactions in the mempool and pick up the higher transaction fee version, they will then discard the lower fee transaction as an invalid transaction since the input/s of the transaction will now be spent.?


https://mempool.space/

In addition to RBF there’s also Child Pays For Parent (CPFP) which is where the user has a transaction stuck in the mempool and so they create a new transaction that spends the output/s from this and include a high fee rate on that so that a miner picks this transaction as well as the low fee rate one up (since you can’t process the later one without the first one also being processed).?

There are also Bitcoin services like MempoolAccelerator which allows for the transaction originator (or anyone with an interest in getting the transaction processed) to pay an additional fee directly to a miner in order to entice them to include the transaction within the next block.

https://mempool.space/accelerator ?

In the unlikely case that the mempool remains highly congested and you don’t increase the fee that you’re willing to pay then the transaction could sit within miners’ mempool for up to 2 weeks before it’s normally pruned to free up memory. However this doesn’t mean the transaction is invalid, nor does it mean that it will now never get confirmed, as there could always be a miner who doesn’t prune it from their mempool and later confirms it. In fact in 2017 some low fee transactions took several months before they were later picked up and confirmed. However it’s much more likely that the transaction eventually becomes invalid since the sender creates new transactions which spend the same inputs (e.g a RBF transaction or just a normal transfer of funds).?

In the Ethereum world there’s a similar trick to replicate the RBF model of Bitcoin. If you have a transaction stuck in the mempool then you can create a new transaction which pays a higher gas fee and sends 0 ETH to yourself but importantly you set it to have the same nonce as the stuck transaction.

But what is a nonce and how does this unstick your transaction?

On Ethereum, every transaction you create from your address is effectively numbered - this is called the nonce. This means the first transaction from your address has nonce = 0, the next has nonce = 1 etc. The blockchain will process transactions from your address by increasing nonces therefore if you have a transaction with nonce 32 which is ‘stuck’ in the mempool then transactions of nonce 33 onwards won’t be processed.?

Therefore if you create a new transaction with the same nonce as the stuck transaction and include a higher transaction fee, this will be picked up by validators and processed, meaning the previous transaction is invalid and effectively cancelled and you can retry your transaction again with a higher fee.

If you want a lovely visual of the Bitcoin and Ethereum mempools (as well as some other chains) then I recommend TX City’s South Park-esque visualiser:? https://txcity.io/v/eth-btc ?

People = transactions and cars/buses are the blocks.

Kate Baucherel

Speaker | Blockchain Explainer | Author

2 个月

Love this. I use the road toll analogy too, it's such a good way to visualise.

回复

Great article as usual !

Peter Davey MA, ACA, LLB

Governance, Risk & Compliance (GRC) | Interim, advisory, & consulting | Payments, Clearing & Settlement, Open Banking, Crypto | Head of Compliance, MLRO, CRO, DPO

2 个月

Thanks, interesting.

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了