We have users who want to send the money from one address to another, miners who will write those into new blocks, and nodes who will store a copy of that list with transactions just in case. But how can we actually get a transaction from being basically a request in your wallet to a reality in another person’s wallet? How do wallets tell the miners “Hey I have a new transaction! Can you write it down?” If we connect directly with the miners, they could know where or who we are. And it would be super inefficient. Do we have to send a message to all miners? How do we even know who they are?
What we can add is something like a scratch pad for transactions that are so new they haven’t yet got included in the upcoming block, pending transactions so to speak. We write them in there in the meantime, and then toss the page away once they’re written properly. That way we kind of quickly know if the transaction exists, before it gets recorded forever. Like a subway platform for transactions, you can see them waiting, already paid their ticket, but still waiting for the train.
That disposable pad is called the mempool, short for memory pool. It’s like a big, well… pool filled with envelopes of letters that have not been sent yet. How does it work? Let’s follow the path step by step. First the wallet creates a transaction by grabbing one of the bills you have and signing it with your key so it’s official. Then it connects to a node and tells the node about it. This is your point of entrance to the network. Remember how nodes are sharing their list copy with each other to compare and make sure that they all have the same one? Well, they also share between them the signed transactions waiting for miners to pick up. That shared and dynamic (because it changes all the time) list of pending transactions is the mempool. So the transaction gets replicated from one node to the other, until it reaches almost all of them.
You can see this live mempool list of pending transactions on a explorer. You can also see their size and the fees they paid. Remember that miners are connected to nodes too, so they can see this, and automatically pick from this pool the transactions that better suit their interests (the smaller and pricier the better). So the miners are all the time constructing that ideal next block of transactions just in case they’re the lucky one that wins the random lottery. The moment one of them do, it submits the solution to the others, grabs stuff from the mempool, makes a new block, tells others about it, and goes back to mine for the next one. Done, our transaction is now official and cannot be taken back unless we somehow convince most of all other miners and create a new version of reality.