What is Mempool and How Does It Work?

What is Mempool and How Does It Work?

If you have ever interacted with cryptocurrencies, you most probably have sent cryptocurrencies from one wallet to another, and depending on the blockchain, you might have waited for some time before the transfer went through. While it might be frustrating when your transaction is in a processing state, have you ever wondered where your cryptocurrencies are at that moment? 

When these transaction delays happen, your cryptocurrencies go to a special place called a mempool, but what exactly is this mempool and how does it work? Let's take a look.

What is Mempool?

A mempool, which is a combination of “Memory” and “Pool”, can be described as a waiting area within a blockchain node where transactions that are yet to be approved are stored. When a transaction is initiated, it enters the queue of the mempool before it is processed and confirmed on the blockchain. 

Mempools play a huge role in the workings of a blockchain node. Approving a transaction on the blockchain involves including it in a newly created block. However, not all participants in the network have the ability or the authority to create new blocks. In a proof-of-work protocol, used by Bitcoin and many other blockchains, only crypto miners have the ability to create blocks, while in proof-of-stake protocols, used by the likes of Ethereum, only validators possess this ability. 

When you make a transaction and sign it, you depend on either a miner or a validator to include it in a block and spread it throughout the network. However, there may be a time gap between the approval of the transaction and its incorporation into the network. During this time, the transaction needs a place to wait, and this place is referred to as a mempool. 

How Does a Mempool Work?

Before we look at the workings of a mempool, it is important to understand that each blockchain does not have only one mempool, but rather has a mempool within every node on the chain. Each of these mempools receives different transactions at different times. So how do they work?

Transactions within a mempool can be in one of two states: queued or pending. At first, when transactions enter the mempool, they are in a queued state. Once the node validates these queued transactions, they transition into a pending state, and miners can only include these pending transactions in a block.

Let’s look at the example of mempool in action. Let’s say you send your friend 5 ETH, you enter your friend’s wallet address, specify the gas fee, and click send. 

During this time, your transaction enters your node’s mempool as a queued transaction. From there, it moves across the network of nodes but does not immediately join the blockchain. Instead, each node performs checks to ensure the validity of the queued transaction. If the nodes do not encounter any issues, the transaction moves to pending status. Eventually, a validator (since we are using Ethereum), from their respective node’s mempool, selects the pending transaction and includes it in a new block. This is when your transaction gets approved, and your friend receives 5 ETH coins. 

Common Problems With Mempools

As you can see this is a big process that has many participants and involves a lot of actions. Because of this, it’s inevitable that there can be some problems that show up from time to time. These problems usually cause your cryptocurrencies to remain in the mempool for extended periods of time, and you sit there waiting for approval. Let’s take a look at some of the most common reasons for this happening. 

You set the gas fee very low

We used Ethereum as an example, and it was not unintentional. Ethereum transactions commonly get stuck in mempools, and there is one common reason for this happening. The reason is that you set the gas fee very low, making it unattractive for a validator to include your transaction in a block. If the gas fee you offer is very low, the network might never accept your transaction, because there are other transactions that offer bigger gas fees. Because of this, validators might overlook your transactions in favor of the more expensive and lucrative ones. 

Network is congested

The biggest reason transactions get stuck in the mempool is due to network congestion. With a large number of transactions being submitted simultaneously, miners and validators need to prioritize which transactions to process first. In this case, they prioritize transactions with higher rewards.

During periods of high network congestion, transaction fees tend to increase as participants are willing to pay higher fees to ensure their transactions are processed promptly. Therefore, if you submit a transaction during a busy period, you may need to match the fees others are willing to pay to have your transaction prioritized. 

While this might seem like greed on the part of block creators, it’s a fundamental part of the system. When the network is congested, lower-fee transactions are automatically removed from the mempool to make room for those offering higher fees. 

To Sum Up

In conclusion, the mempool is an essential part of blockchain nodes, serving as a waiting room for transactions before they are processed and approved. It allows for the validation and inclusion of transactions in new blocks by either miners or validators. While there are multiple mempools in each node on the chain, transactions in the mempool can be in either a queued or pending state, depending on the validation status. 

When we see transactions being stuck in mempools, it’s commonly caused by network congestion and you offering low gas fees. When there is a big demand for transaction verification, miners and validators are unable to process every transaction simultaneously and they need to prioritize them in some way. This prioritization is done by looking at the rewards offered, and when you offer low gas fees, they are more likely to process other transactions before yours, and in some cases, they might even cancel your transaction. 

FAQs on What is Mempool?

Why do transactions get stuck in mempools?

There are multiple different reasons why transactions might get stuck in a mempool, but in most cases, it’s about high demand on blockchain. When there are a large number of transactions happening simultaneously miners or validators prioritize transactions that pay higher fees. This causes your transaction to get stuck in a mempool if you are not paying a high enough fee to make your transaction attractive for these miners and validators. 

What is mempool used for?

Mempools are used to create a flow of transactions in the blockchain. It stands for “memory pool” and gathers and stores cryptocurrencies when they are in the middle of confirmation. This is used in order to make sure every transaction goes through when blockchain is in high demand. Transactions that are sent, are stored in these mempools before validators or miners are able to process them and include them in the blockchain. So, this is sort of a storage of cryptocurrencies that are in the middle of transactions.