Marketplace has launched, further enabling blockchain developers! Learn more

How to Access Bitcoin Mempool

September 21, 2022

Overview

Bitcoin is the father of blockchain technology. With Bitcoin started a new era of blockchain and decentralization. Bitcoin enabled everyone to make the peer-to-peer transactions they enjoy today; this guide will teach you how to get these transactions from the Bitcoin mempool.

Prerequisites:
  • Terminal/cmd (CLI).
  • Bitcoin Node.
  • Love for decentralization.

What is Bitcoin Mempool?

The transactions which are sent on the Bitcoin Network are not added directly to the blockchain. All of the valid transactions have to enter a waiting area before they are accepted in a block. This waiting area is known as the mempool. If the size of the mempool is large, it indicates high traffic on the network which results in longer transaction confirmation times and higher transaction fees.

Note: In standard practice, Bitcoin is protocol/network, and bitcoin or BTC is the currency.

The Bitcoin transaction fee is measured in the number of satoshis paid for per byte of the transaction. Satoshi is the smallest unit of the native currency bitcoin of the Bitcoin network, where 1 bitcoin = 100 Million satoshis. Miners give priority to the transactions in the mempool with high transaction fees. But since the SegWit upgrade, a few things changed around Bitcoin transactions. It introduced a new transaction known as a SegWit transaction to increase the number of transactions per Bitcoin block. It fixed two issues: 1. It increased the number of transactions on Bitcoin per second, 2. It fixed the issue of transaction malleability.

Before SegWit, blocks or transactions were measured in bytes, and each block was limited to 1 MB (MegaByte) or 1 Million bytes. After SegWit, transactions, and blocks are measured in weight units; these weight units are used to measure Bitcoin data and compare transactions.

The next concept to cover is vByte. A vByte is equivalent to four 4 weight units. A Byte of data takes 1 vByte (4 weight units) for a legacy transaction. Whereas, for a SegWit transaction, a Byte of data takes 1/4 vByte (1 weight unit). This discount allows the blocks to be filled with 4 times more transactions. The current Bitcoin block size is limited to 1 vMegabyte/ 1 million vByte/ 4 million weight units. Most wallets calculate transaction fees in terms of satoshis/vByte, which is paid per vByte of data used.

Bitcoin mempool analysis use cases:

Mempool analysis helps us understand the congestion/traffic on the network, which ultimately helps us calculating transaction fees.

Let us now access the mempool and get some transactions data from the pool.

Booting a Bitcoin node

For our purpose today, we need a Bitcoin node to access the blockchain data. Launching our own node here will be very expensive and time-consuming, given the large amount of data on Bitcoin. We will instead get a free trial Bitcoin node from QuickNode.

Screenshot of Quicknode Bitcoin endpoint

Copy and save the HTTPS URL of your node as it will be needed later.

How to access Bitcoin Mempool/How to get pending transactions from Bitcoin

We will use Bitcoin RPC methods to get mempool data getrawmempool method to be specific Open terminal/cmd and copy-paste the following:

how to access bitcoin mempool how to get pending transactions from bitcoin

Copy
curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getrawmempool", "params": [true]}' -H 'content-type: application/json' <QUICKNODE_BITCOIN_URL>

Replace QUICKNODE_BITCOIN_URL with your Bitcoin node’s HTTPS URL, which we got in the last step. Above is a cURL request to our node along with the getrawmempool method. 

The output should be similar to this.


Now let us understand the output body. The above method gives out a list of pending transactions currently in the mempool. We will take out a single transaction and go through each field.

how to access bitcoin mempool how to get pending transactions from bitcoin

Copy
{
    "result": {
        "2d1228abf06836b1173936061fec0384e82e3b684d7950a27f06a06f587400d3": {
            "fees": {
                "base": 0.00111999,
                "modified": 0.00111999,
                "ancestor": 0.00111999,
                "descendant": 0.00111999
            },
            "size": 90826,
            "fee": 0.00111999,
            "modifiedfee": 0.00111999,
            "time": 1629052793,
            "height": 695936,
            "descendantcount": 1,
            "descendantsize": 90826,
            "descendantfees": 111999,
            "ancestorcount": 1,
            "ancestorsize": 90826,
            "ancestorfees": 111999,
            "wtxid": "b3b49bb3dcae483d579710a2e1f9c7ed585ab35e2a8cb941ff8cb27ea8adec20",
            "depends": [],
            "spentby": [],
            "bip125-replaceable": false
        }
    }
}

Explanation of the above JSON output:

Line 3: This is the transaction id by which a transaction on the blockchain is identified.

Line 4-9: Transaction fee breakdown.

Line 10: Size of the transaction as per BIP 141.

Line 11: Transaction fee in BTC (bitcoin).

Line 12: Transaction fee with fee deltas used for mining priority.

Line 13: Time at which the transaction entered in the pool in seconds since 1 Jan 1970 GMT.

Line 14: Height of the blockchain (latest block) when transaction entered the pool.

Line 15: Number of descendent transactions in mempool, including this one.

Line 16: Size of all the descendent transactions in mempool.

Line 17: Modified fees of all the descendent transactions in mempool.

Line 18: Number of ancestor transactions in mempool, including this one.

Line 19: Size of all the ancestor transactions in mempool.

Line 20: Modified fees of all the ancestor transactions in mempool.

Line 21: Transaction id along with witness data.

Line 22: If an unconfirmed transaction is used as input for this transaction, it is to be entered here.

Line 23: If another unconfirmed transaction is using data from this transaction, it must be entered here.

Line 24: A Boolean value showing that whether the transaction can be replaced due to BIP 125.

Now to get the actual transaction data we will have to use another method getrawtransaction which will return information about a particular transaction. Copy-paste the following in your terminal/cmd:

how to access bitcoin mempool how to get pending transactions from bitcoin

Copy
curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getrawtransaction", "params": ["2d1228abf06836b1173936061fec0384e82e3b684d7950a27f06a06f587400d3", true]}' -H 'content-type: application/json' <QUICKNODE_BITCOIN_URL>

Replace QUICKNODE_BITCOIN_URL with your Bitcoin node’s HTTPS URL, which we got in the last step. Above is a cURL request to our node along with the getrawtransaction method. To get this, we will ping our node to resolve the method. We have to pass two parameters for this method. The first is the transaction id of the transaction to be queried. The second is a boolean value which, if set false, returns a string; otherwise, it returns a JSON object.

We have set the second parameter as ‘true’, so the output should look like this.


Explanation of the transaction object pasted here:

Line 3: Transaction id by which a transaction on the blockchain is identified (same as provided).

Line 4: Transaction hash which from txid for witness transactions.

Line 5: Size of the transaction as per BIP 141.

Line 6: Virtual size of the transaction which from size for witness transactions.

Line 7: The version number of the transaction, currently 1 or 2. If 2, it means BIP 68 applies.

Line 8: Lock time is specified as a block number. If a lock time is mentioned, then that transaction can only be added to a block if the lock time block has been passed. For example, if the lock time is mentioned as 30, miners can only pick up the transaction after block number 30 has been mined.

Line 9-20: Vin shows the list of transactions in mempool this particular transaction is using as input.

Line 21-33: Vout shows the list of transactions in mempool using this particular transaction as input.

Line 34: Block hash, null here as the transaction is not confirmed yet.

Line 35: Number of confirmations the transaction has passed.

Line 36: Time at which the transaction entered in the pool in seconds since 1 Jan 1970 GMT.

Line 37: Time at which block was mined in which the transaction was added, null here since the transaction is pending.

Line 38: Serialized, hex-encoded data for 'txid'

By analyzing the above data we can understand in and outs of a Bitcoin transaction. Bitcoin transactions are pretty complex, but getrawtransaction method gives out the raw transaction information which is easy to look at and understand.

Conclusion

Congratulations on mastering the Bitcoin mempool. Today in this guide, we learned what Bitcoin mempool is, the use of Bitcoin mempool, how to access Bitcoin mempool/how to get Bitcoin pending transactions, and how to get Bitcoin pending transaction data.

Subscribe to our newsletter for more articles and guides on Ethereum. If you have any feedback, feel free to reach out to us via Twitter. You can always chat with us on our Discord community server, featuring some of the coolest developers you’ll ever meet :)

Related articles 35

How to do a non-custodial transaction with QuickNode
Originally Published On: Jun 19, 2021
Updated On: Sep 9, 2022

Private keys are one of the most... A non-custodial wallet is a... Custodian of Private... At We could use pretty much any... We could use any of the many... Let us create a token transfer... Congratulations on making a...

Continue reading
How to Set Up a Near Project from Scratch
Originally Published On: Jan 27, 2022
Updated On: Sep 9, 2022

In this tutorial we will look at... In this section, we will... In this section, we will look at... In this section, we will look at... When writing smart contracts on... In the last section, we looked... In the last section, we looked... In the last section, we looked... We have finally come to the end...

Continue reading
Estimating gas price using pending transactions in Python
Originally Published On: Feb 20, 2021
Updated On: Sep 9, 2022

To send a transaction on the... Gas is the unit to measure the... Why do we want to estimate gas?... Our first step here would be to... For our purposes today, we could... The first thing we’re going to... Now you know how to estimate gas...

Continue reading
Como crear y lanzar un ERC-721 (NFT)
Originally Published On: Dec 27, 2021
Updated On: Sep 9, 2022

Coleccionables digitales que son... Fungible significa que es lo... ERC es la abreviación para... Ahora que conocemos qué es y... Antes de escribir nuestro... Felicidades por crear tu propio...

Continue reading
How to Mint an NFT on Polygon with Ethers.js
Originally Published On: Mar 28, 2022
Updated On: Sep 9, 2022

This guide demonstrates how to... Ethers.js is a complete Ethereum... As a reminder, the act of... We will deploy our contract on... Time to write the code! Start by... Note, you will need some... That’s it! You have minted an...

Continue reading
How to access Ethereum Mempool
Originally Published On: Oct 15, 2020
Updated On: Sep 15, 2022

On Ethereum, when a transaction... In blockchain terminology, a... For the purpose of this guide,... First, query the Let’s examine how to subscribe... This short guide showed you how...

Continue reading
The Web3 Developer Stack
Originally Published On: Jul 3, 2021
Updated On: Sep 15, 2022

A developer stack is a bag of... If we can imagine web3 as a car... The Chainlink price feed... Head over to the We’ll need a Kovan node to... We’ll now write a short... Congratulations :D You’ve taken...

Continue reading
How to Mint NFTs on the Stacks Blockchain
Originally Published On: Aug 19, 2022
Updated On: Sep 9, 2022

Stacks is an emerging blockchain... The Stacks ecosystem has adopted... Open up a terminal window and... Implementing the SIP-009... This section will demonstrate... The moment you've been waiting... Awesome Work! You’ve learned how...

Continue reading
Introduction to Scaffold-ETH 🏗
Originally Published On: Oct 7, 2021
Updated On: Sep 9, 2022

Developing applications involves... First of all, before getting... Scaffold-ETH comes with a demo... We will set up a QuickNode... Congratulations, and thank you...

Continue reading
How to connect to Ethereum using PHP
Originally Published On: Jun 11, 2021
Updated On: Sep 9, 2022

PHP is a very popular choice... Before installing the web3.php,... We could use pretty much any... Now, make a PHP script file... Congratulations on connecting to...

Continue reading
How to use Subspace with QuickNode
Originally Published On: Sep 8, 2020
Updated On: Sep 9, 2022

In this guide, we'll understand... To install Subspace, we'll need... For our purposes today, we could... Now let's create a short script,... Run the file using the node...

Continue reading
How to Connect Your Dapp With MetaMask Using Ethers.js
Originally Published On: Dec 13, 2021
Updated On: Sep 9, 2022

In our dApp, we will have a... A dApp is an application that... We will need to install the... Ethers.js is a lightweight... With this application, we will... Next, we will create a function... After connecting to MetaMask, we... To handle the wallet address of... This section will show us how to... In this tutorial, we...

Continue reading
How to Lazy Mint an NFT on Rarible with Rarepress
Originally Published On: Feb 23, 2022
Updated On: Sep 9, 2022

NFTs are great for creators to... To mint an NFT, you write data... Lazy Minting is a process in... We will write some JavaScript... Rarepress interacts with the... Now that we have everything in... Congratulations on listing your...

Continue reading
How to get the balance of an ERC-20 token
Originally Published On: Jun 14, 2021
Updated On: Sep 21, 2022

When a new token is made on the... You could use any Ethereum... Now that you've done the legwork... Getting the ERC20-Token Balance... In the top of your... ABI is short for You will most likely interact... You can use a similar process... We now have a connection to an... Having made it to the end, you...

Continue reading