## 3 Methodology and Implementation
### Technological Stack Analysis  
This section discusses the evolution of blockchain technology and its applications in supply chain management, focusing on smart contracts and their role in the proposed system architecture. Initially introduced by [PERSON] in 2008 with Bitcoin, blockchain implementations have diversified over time, leading to variations in codebases, algorithms, and philosophical approaches. These changes have extended to the development of smart contracts, which automate processes in supply chain management. Figure 3: An overview of project flow diagram [30]. The first blockchain implementations, including Bitcoin, prioritized creating secure and immutable transaction ledgers rather than enabling smart contracts. Initially, smart contract logic was implemented using \"OP-CODES\", logical instructions embedded in the blockchain's scripting system. These implementations were not Turing-complete, limiting their capabilities to increase network security. Ethereum, introduced as a Turing-complete blockchain, revolutionized smart contract development by proposing the Ethereum Virtual Machine (EVM). EVM serves as a decentralized, deterministic, and sandboxed environment that executes and enables the usage of smart contracts. Ethereum's adoption and EVM's compatibility with other chains have made it a popular choice for smart contract implementation. The proposed system architecture leverages Ethereum due to its Layer-1 blockchain status, interoperability with Layer-2 chains, and extensive adoption. Solidity, the native programming language for EVM, is chosen for smart contract development. The architecture incorporates Truffle Suite for managing smart contracts offering development, testing, debugging, and deployment tools. Ganache, part of the Truffle Suite, provides a local blockchain environment for cost-effective testing and development. Oracles are crucial in the proposed system, bridging the gap between smart contracts and real-world data sources. Chainlink is selected as the oracle provider due to its decentralized and integrable nature. Oracles retrieve data such as temperature, product conditions, and transfer times, enhancing the smart contract's decision-making capabilities. The Ethereum blockchain is utilized for data storage, ensuring transparency, immutability, and tamper-proof data records. By using blockchain, the system minimizes the risk of data alteration and deception among participants. The proposed system architecture is designed to manage the distribution of cold-chain critical medicines but is adaptable to various supply-chain applications. It provides a high-level view of the implementation, with defined parties, processes, rules, and restrictions to increase the system's robustness. Well-defined rulesets for events and actions are recommended for event-driven and critical business applications, especially in the context of smart contracts' irreversible transactions and tamper-proof nature. Overall, the proposed architecture combines blockchain technology, smart contracts, oracles, and Ethereum to create a secure, transparent, and automated supply chain management system with the flexibility to adapt to different use cases. Our proposed system defines the following rulesets and restrictions in it:  
1. Only the manufacturer can add products to the supply chain. 2. Parties cannot change their roles in the supply chain environment. 3. One can only add a party to which they have a direct connection. 4. Parties can only see details of parties to which they have a direct connection. 5. Everyone can see the status of the transferred product. 6. A damaged product cannot move forward in the chain. 7. A product set for return cannot move forward in the chain
8. A product set for return should stop at its predefined return location. 9. A party with a product in its inventory cannot be removed from the chain. 10. Parties should pay predefined fees to their receiver. 11. Parties can only withdraw the amount in their wallets from the contract.