getmempoolentry - Bitcoin Cash

This method returns mempool data for a single transaction that is currently in the mempool, including its fees, size, and ancestor and descendant counts.

Parameters

ParameterTypeRequiredDescription
txidstringYesThe transaction id, which must be in the mempool

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getmempoolentry",
    "params": ["10b54fd708ab2e5703979b4ba27ca0339882abc2062e77fbe51e625203a49642"],
    "id": "getblock.io"
}'

example.js

javascriptconst axios = require('axios');
const { data } = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
  jsonrpc: '2.0', method: 'getmempoolentry',
  params: ['10b54fd708ab2e5703979b4ba27ca0339882abc2062e77fbe51e625203a49642'], id: 'getblock.io'
});
console.log(data.result.fees);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'getmempoolentry',
        'params': ["10b54fd708ab2e5703979b4ba27ca0339882abc2062e77fbe51e625203a49642"],
        'id': 'getblock.io'
    }
)

print(response.json()['result'])

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "getmempoolentry",
            "params": ["10b54fd708ab2e5703979b4ba27ca0339882abc2062e77fbe51e625203a49642"],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;

    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "error": null,
    "id": "getblock.io",
    "result": {
        "size": 226,
        "time": 1617180599,
        "height": 684634,
        "descendantcount": 1,
        "descendantsize": 226,
        "ancestorcount": 1,
        "ancestorsize": 226,
        "fees": {
            "base": 2.26e-06,
            "modified": 2.26e-06,
            "ancestor": 2.26e-06,
            "descendant": 2.26e-06
        }
    }
}

Response Parameters

ParameterTypeDescription
errornull|objectError object when the call fails, otherwise null
idstringRequest identifier matching the request
resultobjectMempool entry object for the transaction

Result Object

FieldTypeDescription
sizenumericTransaction size in bytes
timenumericTime the transaction entered the mempool
ancestorcountnumericNumber of in-mempool ancestor transactions
descendantcountnumericNumber of in-mempool descendant transactions
feesobjectBase, modified, ancestor, and descendant fees in BCH

Use Cases

  • Fee Bumping: Read ancestor fees before deciding on a child-pays-for-parent spend
  • Confirmation Estimates: Assess a transaction's position by its fee rate
  • Chain Limits: Check ancestor and descendant counts against mempool limits
  • Stuck Transactions: Diagnose why a low-fee transaction remains unconfirmed

Error Handling

Error CodeMessageDescription
-8Invalid parametertxid is not a valid 64-character hex string
-5Transaction not foundNo transaction with the given id is available; a txindex may be required
-32603Internal errorNode failed to read the transaction