Bitcoin answers the question, “Which transaction to keep?

The way Bitcoin answers this question is brilliant.

Here’s how…

Every node on the Bitcoin network shares information about new transactions.

Transactions made on the Bitcoin network are NOT directly added to the blockchain. They are first collected and stored in what’s called the”memory pool”.

EVERY computer running the Bitcoin program creates a temporary storage area for transactions called the “memory pool”. Also known as “mempool” for short.

Each Bitcoin node has its own mempool, where it stores the queue of transactions that it has checked and considers valid.Bitcoin Node's Memory Pool

Broadly speaking, a mempool is an organized queue where transactions are stored and sorted before being added to a newly created block.

  • The memory pool holds “fresh” or unconfirmed transactions (stored as individual transactions).
  • The blockchain holds “archived” or confirmed transactions  (packaged in “blocks”).

All bitcoin transactions are simply “unconfirmed” transactions and only exist in the mempool before they’re “confirmed” and added to the blockchain.


In the Bitcoin network, all full nodes have a memory pool. 

All Bitcoin nodes have a memory pool

Let’s say you initiate a transaction on this side of the network (purple transaction).

And then go over here, and use the same bitcoin and insert the red transaction in this computer.

If you notice, these two transactions are NOT written directly to the file. Both transactions are simply stored in the memory pool of each computer first.

Both transactions are stored in memory pool

So both transactions will propagate across the network.

This computer will REJECT the red transaction because they’ve already received the purple one.

Transaction is rejected from mempool

So now BOTH transactions are on the network.

But they are NOT written to the file yet, so the file still hasn’t been updated.

Both transactions are waiting in mempool

What will happen then is all of these computers will work and try to get their transactions from their memory pool onto the file.

They will compete to be the first ones to get their memory pool transactions added to the top of the file.Bitcoin mining nodes compete

Let’s say this computer (in yellow) is the first one to be able to do it.

Bitcoin node first to add transaction to blockchain

It adds its transaction from the memory pool into the file:

Bitcoin nodes adds transaction to blockchain

And when it’s done that….

It will pass their updated copy of the file to everyone else they are connected to….

Bitcoin node shares blockchain copy

And they will update their copies.

In the illustration below, this node here receives the updated file that contains the purple transaction spending the same bitcoin.

Bitcoin node kicks out conflicting transaction

What happens to the conflicting red transaction in its memory pool?

Since the same bitcoin has already been spent in the purple transaction, it will kick out the red transaction from their memory pool!

This node will then pass on the updated file.

And the other node(s) will do the same thing…it will kick out any conflicting transactions in its memory pool.

All Bitcoin nodes kick out conflicting transaction

All computers now have the updated file.

So that’s how you solve the problem of having two conflicting transactions on the network.

You literally just have a “waiting area” (mempool) for pending transactions and nodes compete and try to add their transactions to the file.


In this example, the purple dude would receive the bitcoin…Bitcoin transaction is successful 

But when yo shady self tries to spend the same bitcoin with the red dude, it’s not going to work.Bitcoin transaction fails

This process of nodes competing to try and get their transactions from their memory pool onto the file (“the blockchain”) is called MINING.