In recent years, COVID-19 has impacted millions of individuals worldwide, resulting in numerous fatalities across several countries. While RT-PCR technology remains the most reliable method for detecting COVID-19, this approach is expensive and time-consuming. As a result, researchers have explored various machine learning and deep learning-based approaches to rapidly identify COVID-19 cases using X-ray images. Machine learning based models can reduce costs and have shorter processing times. However, preserving patient confidentiality poses challenges within such third-party-controlled systems, potentially failing to safeguard patients from potential disgrace and discomfort. Nonetheless, blockchain technology offers the potential to securely store sensitive medical data anonymously, without requiring third-party intervention. Consequently, the combination of deep learning and blockchain might offer a viable solution to mitigate the spread of COVID-19 while ensuring patient privacy protection. In this paper, we propose a hybrid model of blockchain and deep learning model for automatically detecting COVID-19 using chest X-rays (CXR). The deep learning model includes a stacking ensemble of three modified pre-trained Deep Learning (DL) models: VGG16, Xception, and DenseNet169. The model obtained an accuracy of 99.10% and 98.60% for binary and multi-class respectively. Further, to ensure COVID-19 patients’ privacy and security, the Ethereum blockchain has been adopted to store information related to COVID-19 cases. In addition, a smart contract on the blockchain has been designed for handling X-ray images in the Interplanetary File System (IPFS).