The outbreak and global spread of the novel coronavirus (COVID-19) have brought severe challenges to the world, which has caused a shortage of medical resources in various countries. This disease seriously threatened people's lives and property safety and caused large economic losses. The rapid spread of COVID-19 has put forward higher requirements for the governance of society and cities, especially in terms of transparency, credibility, efficiency and fairness, data sharing, and collaboration, which is an urgent need to build safe and efficient infection prevention solutions. This study proposes an epidemic prevention and control system based on blockchain technology and implements an emergency response system through a secure data-sharing mechanism to quickly discover potential infectious viruses. The blockchain can integrate discrete data from multiple parties and build a contact tracking system for infected persons to prevent the spread of the epidemic. To prevent and control the epidemic scientifically and effectively, we accurately analyzed the probability that each contact instance may be infected so that different isolation treatment measures can be adopted. Meanwhile, blockchain can be used to achieve immunization certificates to protect user privacy, which can curb the spread of the epidemic while facilitating people's daily routines. This study puts forward new ideas for epidemic prevention and control schemes, which is quite meaningful to improve the health and sustainability of urban cities.