In modern society, the food supply chain management system has become an important research area realized nationally and internationally, which has established a collaborative relationship between producers, manufacturers, processors and retailers. Now, consumers are more interested in food quality, safety and the authentication of the products. Food safety has become an important issue in public health in the food market because people of all types and races around the world are affected due its poor quality. The traditional supply chains are centralized and face different issues such as lack of transparency, accountability and audit ability. The general issues in supply chain management include lack of communication, trust among the stakeholders, and interference of entities and wastage of food. A lot of work has been completed by researchers to address the above issues, but still, there is a need for effective mechanisms for the modeling of supply chain management systems. In this paper, a trusted, self-organized, traceable formal system based on blockchain and Internet of Things (IoT) is developed by using wireless sensors networks and finite automata. In the proposed model, smart contracts are designed to assure the automated payment procedures. The proposed model reduced the need for centralized authority. Unified Modeling Language (UML) is used to realize the requirements, and automata is used to capture behavior of the system. A blockchain-based model is used to provides the privacy and security mechanism for the transitions record. Wireless sensors are used to sense the information, and actors are used for decision making in case of any violation in the contact. A lot of work has been completed by researchers on smart contracts. Different smart contracts are designed to achieve the better traceability among producers, transporter/logistics and consumers. Our system provides the smart contract algorithm to show the interaction of entities in the food supply chain management system. Vienna Development Method-Specification Language (VDM-SL) is used to describe the formal system and the VDM-SL toolbox is used for the validation and analysis of the system.