Traditional medical system solves problems such as medical record management, patient information storage, medical resource scheduling, and so on. However, it suffered from shortcomings such as medical privacy breaches, data security concerns, and high loads on end devices when dealing with everincreasing data volumes and complex access control requirements. To solve the above problems, this paper proposes a traceable encryption scheme based on smart contract and fog computing for medical data privacy protection. By introducing authorization mechanisms and revocable attributebased encryption, the privacy of medical data is effectively protected and the abuse of key is avoided. Additionally, data security is further enhanced by embedding user information in private keys. As the participant of access control, smart contract is responsible for the authentication of the user’s authorization, and part of the decryption operation is undertaken by the fog node, thus reducing the load of the terminal device and achieving load balancing. In comparison with other similar schemes, the proposed approach demonstrates higher computing and storage efficiency.