n uses a consensus algo- rithm to verify blocks in a decentralized fashion. The main challenge in developing consensus algorithms is how to make the algorithm immune to the existence of mali- cious nodes in the network. The most used consensus algorithms are job proof (PoW), stake proof (PoS), and practical byzantine fault tolerance (PBFT) [9]. 7.3.2 SMART CONTRACTS AND AI Smart contracts are scripts stored in the blockchain and have a unique address. The script is executed when a transaction addresses the smart contract [10]. Smart contracts resemble legal contracts where a transaction is not completed until all parties meet the conditions set in the contract. Smart contracts could be used to check that the medical personnel are authorized to edit a patient's record before appending new data to the record. Artificial intelligence (AI) can expand the functionalities of blockchain and increase the security of blockchains. AI could detect anomalous readings from healthcare IoT sensors and discard them, which reduces the load on the blockchain network and makes the data used cleaner. AI can also be used to improve the effi- ciency of consensus algorithms by detecting malicious nodes. Moreover, integrating smart contracts with AI can expand the capabilities of smart contracts beyond if-else conditions. Smart contracts backed with AI can fulfill the automation expected from healthcare IoT applications. For example, AI-powered smart contracts can automat- ically notify a doctor if his patient is having a seizure and automatically records the event in the patient's record. 7.4 INTEGRATED BLOCKCHAIN AND MEC Privacy and security of data is an essential requirement for all healthcare applications. Integrating blockchain and healthcare IoT networks makes the data more secure since it is stored in an encrypted block. Encrypting blocks and storing the blockchain Integrated Blockchain and MEC Systems requires computation capabilities not found in most healthcare IoT devices. Therefore, the data does not get encrypted until it 