Frontiers in Business, Economics and Management ISSN: 2766-824X | Vol. 17, No. 3, 2024 121 Blockchain Technology in Supply Chain Management: Developing Smart Contracts Based on Python Xiang He Faculty of Management, University of Science Malaysia, Penang, Malaysia xxxiang1@student.usm.my Abstract: With the development of the global economy and the progress of science and technology, the importance of supply chain management in modern economic activities has become increasingly prominent. However, traditional supply chain management is characterized by problems such as information silos, low transparency, and difficulties in traceability, which seriously affect the efficiency and security of the supply chain. The introduction of blockchain technology provides a new technical path and solution to solve these problems. This paper explores the application of blockchain technology, especially smart contracts, in supply chain management. By developing Python-based smart contracts, this paper verifies the effectiveness of blockchain technology in enhancing supply chain transparency, efficiency, security, and trust. In addition, this paper demonstrates the current status and challenges of the application of blockchain technology in supply chain management through literature review and case study analysis, and points out the direction of future research. The findings of this paper show that the application of blockchain technology in supply chain management has significant advantages, but it is still necessary to further optimize the performance and security of smart contracts and explore more application scenarios. Keywords: Blockchain technology, Supply chain management, Smart contract, Python development, Transparency, Efficiency, Security, Trust. 1. Literature Review 1.1. Blockchain Technology Overview Introduced by Satoshi Nakamoto in 2008, blockchain technology has quickly emerged as a significant driver of innovation across various industries, owing to its decentralized, tamper-resistant, transparent, and secure nature. The distributed ledger system in blockchain allows numerous nodes to collaboratively maintain a secure and transparent database via a decentralized network. One of blockchain's core attributes is decentralization. Traditional centralized systems typically place data control and management in the hands of a single institution, which brings with it the risks of a single point of failure and potential data tampering. Blockchain addresses this issue by removing dependence on a single intermediary through its distributed network, thereby enhancing system resilience and data security. Blockchain’s tamper-resistance is achieved via encryption algorithms and consensus mechanisms. Each block contains the hash value of the previous block, establishing a linked chain structure where any tampering with a block’s data would disrupt the entire chain. This characteristic ensures the integrity and trustworthiness of the data. Transparency, another key feature of blockchain technology, allows all participants in the network to view and verify transaction data recorded on the blockchain. This transparency is crucial in supply chain management, where real-time information sharing among all parties can significantly enhance both transparency and traceability. The security of blockchain is also reinforced by its encryption methods and decentralized structure. Every block is safeguarded by encryption, ensuring that only users with the correct key can access or modify the data, thus preserving data privacy and security. 1.2. Smart Contracts and Their Applications Smart contracts, a critical component of blockchain technology, were first conceptualized by Nick Szabo in the 1990s, though their practical implementation became possible only with the advent of blockchain. Smart contracts are automated protocols running on blockchain networks, designed to automatically execute contract terms when pre- defined conditions are met [6]. By encoding contract terms into code, smart contracts minimize or eliminate the need for human intervention, thereby reducing labor costs and the risk of human error. In the context of supply chain management, smart contracts can automate processes such as payments, transfer of goods, and acceptance of deliveries, leading to significant improvements in operational efficiency. Smart contracts have found extensive use in supply chain applications, including automated payments, supplier verification, and logistics tracking. For instance, Christidis and Devetsikiotis (2016) explored the use of smart contracts within the Internet of Things (IoT), noting that these contracts can streamline supply chain operations by automating transactions and reducing the likelihood of errors or human interference. Similarly, Saberi et al. (2019) introduced a supply chain management framework leveraging blockchain and smart contracts, highlighting its benefits in enhancing efficiency and curbing fraud. 1.3. Challenges and Current Status of Supply Chain Management Traditional supply chain management is fraught with challenges, such as information silos, lack of transparency, and difficulties in tracking. Information silos occur when different parts of the supply chain do not effectively communicate, leading to delayed or inaccurate information flow. The lack of transparency in supply chains often makes 122 it difficult to identify and address unethical behavior, which in turn hampers the overall efficiency and credibility of the supply chain. Blockchain technology promises to address these issues fundamentally. Kshetri (2018) found that blockchain can greatly improve transparency and traceability within supply chains, thus boosting consumer confidence in products. Francisco and Swanson (2018) similarly showcased blockchain's potential in the food supply chain, emphasizing its role in enhancing food safety and quality tracking. In China, a blockchain-based pharmaceutical supply chain management model proposed by Li et al. (2018) effectively demonstrated its strengths in anti-counterfeiting and traceability. Zhang Qiang et al. (2019) also showed through empirical research that blockchain significantly improves the transparency and efficiency of agricultural supply chains. Further validation of blockchain's effectiveness in supply chain management comes from empirical studies and case analyses. Tian (2017) examined the use of blockchain in agricultural supply chains through case studies, proving its effectiveness in enhancing transparency and trust. Caro et al. (2018) corroborated blockchain's effectiveness in logistics through experimental research, showcasing its potential in reducing logistics costs and improving operational efficiency. To conclude, while research on blockchain technology’s application in supply chain management has yielded positive outcomes, there remain areas needing further exploration, particularly in the development and application of smart contracts and empirical analysis of real-world use cases. 2. Empirical Application and Evaluation of Smart Contract Technology in Blockchain Technology for Supply Chain Management 2.1. Python-based Smart Contracts Use Python language to develop smart contracts, simulate the actual application in supply chain management, and verify its functions and effects. Writing a smart contract We will write a simple smart contract for managing product information in the supply chain. The smart contract will realize the following functions: Add products Transfer product ownership Query product information Figure 1. Smart Contract Code Figure 2. Compiling Smart Contracts (1) 123 Figure 3. Compiling Smart Contracts (2) 2.2. Smart Contract Application Validation and Evaluation In this experiment, we conducted a simulation of supply chain management using smart contracts developed in Python. The following steps are used to collect data and evaluate the effectiveness of smart contracts in terms of transparency, efficiency, security and trust enhancement. Table 1. Experimental Steps hardware releases operating system macOS Monterey v12.6.3 Python 3.11 web3 6.20.1 py-solc-x 2.0.3 Deploying Smart Contracts: Deploy smart contracts on the local Ethernet test network (Ganache). Open ganache and you can see that there are 10 available accounts, the first one is 0xcB1E9A59CA8285ca25702f463E396b53790188e2, and the second account is 0x35Ee76E9c7c001045EaABDCd5ed78DE12Bd6E540 Running the above python program, output from the program console, the smart contract is deployed to the 0x4845f50E18B72f14D648F6378Bfa1f4Abc75Ac44 at this address. On ganache you can see also packaged a block, block height of 1, there is a CONTRACTCREATION transaction in the block, which is exactly the contract deployment transaction sent by our program, click on the transaction details you can see that there is a longer TXDATA content, which is the code data of our contract, which represents that the smart contract has been successfully deployed to the ganache This means that the smart contract has been successfully deployed to the ganache test network. Add product: Add product information in the supply chain through smart contract, including product ID, name, quantity, price and owner. From the console output of the program, you can see that the program calls the contract to add the product information. Figure 4. Ganache (1) 124 Figure 5. Program control desk (1) Figure 6. Ganache (2) Figure 7. Ganache (3) Figure 8. program control desk (2) In the ganache interface, the block with a block height of 2 packages the transaction, and the transaction hash is: 0x98524a2af4805d4c23616e09951b85b626a4c410c168a4 03185ced049019bcfd 125 Figure 9. Ganache (4) The added product index is 1. The program then performs a product lookup: Figure 10. Program control desk (3) This matches the product information we added in our code, and it's worth noting here that when we added the product, I am using account 0 (0xcB1E9A59CA8285ca25702f463E396b53790188e2), because the add product owner is recorded as 0xcB1E9A59CA8285ca25702f463E396b53790188e2. Transfer Product Ownership: Using the smart contract function, a product is transferred from one owner to another. Subsequently, the python program calls the transferProduct function to transfer ownership of that product to the Account 1 (0x35Ee76E9c7c001045EaABDCd5ed78DE12Bd6E540) Figure 11. program control desk (4) Meanwhile, on ganache you can see that the transfer of ownership transaction is packed into a block of height 3, with a transaction hash of 0xec7b753d434c50a9b75e04f765b15cca08f026766a395173 6563b272c42a7424 126 Figure 12. Ganache (5) Query product information: Query the detailed information of the product through the smart contract. Querying the product information with index 1 again, we can find that the owner has changed from account 0 (0xcB1E9A59CA8285ca25702f463E396b53790188e2) to account 1. (0x35Ee76E9c7c001045EaABDCd5ed78DE12Bd6E540): Figure 13. program control desk (5) Data collection During the experiment, we recorded the following data: Timestamp of each operation Operation execution time Result of the operation Changes in product information 127 Table 2. Data Analysis (1) Operation Name timestamp executio n time Result Changes in product information Account 0 Add Product 2024-08-09 18:16:30 120ms successes New products added: Product ID: 1 Name: Laptop Quantity: 10 Price: 1000 Owner: 0xcB1E9A59CA8285ca25702f463E396b53790188e2 Account 0 Enquire about products 2024-08-09 18:16:30 20ms successes No change, return product information: Product ID: 1 Name: Laptop Quantity: 10 Price: 1000 Owner: 0xcB1E9A59CA8285ca25702f463E396b53790188e2 Transfer of ownership of product 1 from account 0 to account 1 2024-08-09 18:16:30 81ms successes owner changes, from account 0 to account 1: Product ID: 1 Name: Laptop Quantity: 10 Price: 1000 Owner: 0x35Ee76E9c7c001045EaABDCd5ed78DE12Bd6E540 Account 0 Inquiry Products 2024-08-09 18:16:30 13ms successes No change, return product 1 information: Product ID: 1 Name: Laptop, Quantity: 10 Price: 1000 Owner: 0x35Ee76E9c7c001045EaABDCd5ed78DE12Bd6E540 Try again to transfer ownership of product 1 from account 0 to account 1 2024-08-09 18:16:30 30ms fail The transaction was reversed and the Product 1 information was not changed. 2.2.1. Transparency Evaluation Criteria: Degree of data openness: all product information, transaction records and ownership transfer information are open and transparent on the blockchain. Information traceability: The whole process of each product from addition to ownership transfer is traceable. Analysis of results: All information recorded by the smart contract on the blockchain is open, transparent and traceable. Changes in the status of each product and the transaction process can be accessed by querying the blockchain, ensuring the transparency of the supply chain. 2.2.2. Efficiency Evaluation Criteria: Operation execution time: record the execution time of adding products, transferring ownership and querying product information. Degree of automation: the smart contract processes transactions automatically, reducing manual intervention. Analysis of results: The following are the execution times (in seconds) recorded in the experiment: Table 3. Data Analysis (2) manipulate Average execution time (milliseconds) Add Product 120 Transfer of ownership 81 Search for product information 15 Smart contracts significantly improve the efficiency of the operation, all operations are completed in a short period of time, and the entire automated processing, reducing manual intervention. 2.2.3. Security Evaluation Criteria: Anti-tampering of data: all data are recorded on the blockchain and cannot be tampered with. Operation authority control: only the current owner of the product can transfer its ownership. After transferring from account 0 to account 1 and still trying to transfer the product again with account 0, the operation will not be successful because you are no longer the not the owner of the product, the operation will not be successful: 128 Figure 14. program control desk (6) Result Analysis: Blockchain technology ensures that the data is tamper-proof and all records cannot be changed once written to the blockchain. Permission control of smart contracts ensures that only the rightful owner can transfer the ownership of the product, enhancing the security of the supply chain. 2.2.4. Trustworthiness Evaluation Criteria: Participant Trust: Ensures all stakeholders can access and verify transaction records, thus reducing information asymmetry. Transparent Transactions: An open and transparent transaction process fosters greater trust among all parties. Result Analysis: Blockchain technology allows all participants in the supply chain to view and verify transaction records and product information, effectively minimizing information asymmetry and building trust among stakeholders. The transparency of transactions bolsters confidence in the supply chain's operations. Conclusion: Through experimentation and data analysis, smart contracts have been shown to enhance transparency, efficiency, security, and trust in supply chain management. Specific outcomes include: Transparency: All transaction and product data are open and transparent, ensuring traceability. Efficiency: Smart contracts handle transactions automatically, greatly enhancing operational efficiency. Security: Blockchain's immutable records and permission controls safeguard the legality of operations. Trust: Open and transparent transactions reduce information asymmetry and increase trust among participants. 2.3. Blockchain Implementation Strategy in Supply Chain Management Based on experimental results and data analysis, the following implementation strategies and recommendations can guide the practical application of blockchain technology in supply chain management. 2.3.1. Transparency Enhancement Strategy Approach: Broadly apply blockchain technology across all aspects of the supply chain to ensure that product information, transaction records, ownership transfers, and other data are recorded and stored on the blockchain. Recommendations: Full-Process Data Upload: Ensure that all critical supply chain data—including production, transportation, and delivery—are uploaded to the blockchain for comprehensive transparency and traceability. Open Query Interface: Develop and offer open query interfaces that allow every supply chain participant to access on-chain data at any time, ensuring data openness and transparency. Standardized Data Format: Implement a unified, standardized data format to ensure consistency and standardization of data uploaded at different stages of the supply chain. 2.3.2. Efficiency Improvement Strategy Approach: Leverage smart contracts to automate transactions and information exchanges within the supply chain, boosting operational efficiency and reducing manual intervention. Recommendations: Automated Execution of Smart Contracts: Use smart contracts in supply chain management to automatically execute operations like product additions, ownership transfers, and payment settlements, minimizing delays and errors caused by manual operations. Optimize Smart Contract Performance: Enhance the efficiency of contract execution by optimizing smart contract code and logic, reducing execution time. Deploy Distributed Nodes: Establish distributed nodes among supply chain participants to decrease network latency and improve data processing speed and transaction execution. 2.3.3. Security Enhancement Strategy Approach: Utilize blockchain’s tamper-resistance and smart contracts' permission control mechanisms to strengthen the security of supply chain management and prevent unauthorized operations and data tampering. Recommendations: Permission Management: Assign different levels of permissions based on roles within the supply chain to ensure that only the legitimate owner or an authorized party can modify data or transfer product ownership. Multi-Signature Mechanism: Introduce multi-signature protocols for critical operations to ensure that these actions require authorization from multiple parties before execution, further enhancing security. Regular Security Audits: Conduct regular security audits of smart contracts and the blockchain system to identify and rectify potential vulnerabilities, ensuring continuous system security. 2.3.4. Trust Enhancement Strategy Approach: Leverage blockchain's decentralized and transparent nature to reduce information asymmetry and enhance trust among supply chain participants. Recommendations: 129 Transparent Transaction Process: Make all transaction processes public so that stakeholders can monitor progress and access data at any time, ensuring confidence in the supply chain process. Third-Party Verification: Involve independent third-party organizations to verify on-chain transactions and data, providing additional trust assurances. Education and Outreach: Promote blockchain technology's advantages and applications to supply chain participants through training and awareness programs, increasing trust and adoption across all parties. Conclusion: By implementing these strategies, blockchain technology can significantly impact supply chain management, improving transparency, efficiency, security, and trust. Key areas of focus include: Industry Collaboration: Encourage standardized blockchain technology applications within the supply chain industry and promote collaboration among enterprises and institutions to build a transparent and efficient supply chain ecosystem. Technological Innovation: Continue to innovate in blockchain and smart contract development, advancing the technology’s maturity and preparing for larger-scale supply chain applications. Policy Support: Seek policy support actively and encourage governments and industry associations to guide and endorse blockchain technology in supply chain management, reducing implementation costs and risks for businesses. Business Model Innovation: Leverage blockchain technology’s strengths to innovate business models, such as developing blockchain-based supply chain financial services and advancing supply chain management toward intelligence and digitization. Through these measures, blockchain technology can become deeply integrated into supply chain management, helping companies achieve efficient, secure, transparent, and trustworthy supply chain operations, ultimately generating greater business value. 2.4. Data Analysis and Effect Evaluation By employing the aforementioned data analysis and data mining techniques, differences in smart contract performance across various application scenarios can be identified. The specific analysis results can assist in optimizing the design and deployment strategies of smart contracts, thereby improving the efficiency, security, and transparency of supply chain management. The key conclusions are as follows: Transparency Impact: Smart contracts greatly enhance the transparency of information in supply chain management, with consistent performance across various operations. Operational Efficiency Optimization: Significant differences in the execution times of different operations were observed, with product additions and queries being faster, while ownership transfers were relatively slower. Optimizing smart contract code and logic can further enhance operational efficiency. Security Assessment: Data analysis indicates that smart contracts perform effectively in controlling authority and preventing unauthorized operations. Multi-signature and permission control mechanisms further reinforce system security. Trust Enhancement: The transparency and automation features of smart contracts significantly boost trust among supply chain participants, reducing information asymmetry and enhancing the overall efficiency of the supply chain. 3. Conclusion and Outlook This paper examined blockchain technology’s application scenarios in supply chain management, developed Python- based smart contracts, and evaluated their effects. The findings confirm blockchain technology’s effectiveness in enhancing supply chain transparency, efficiency, security, and trust. Future research should focus on further optimizing the performance and security of smart contracts, exploring additional application scenarios, and providing more support for the digital and intelligent transformation of supply chain management. References [1] Nakamoto, S. (2008). Bitcoin: A Peer-to-Peer Electronic Cash System. [2] Tapscott, D., & Tapscott, A. (2016). Blockchain Revolution: How the Technology Behind Bitcoin Is Changing Money, Business, and the World. Penguin. [3] Zheng, Z., Xie, S., Dai, H., Chen, X., & Wang, H. (2017). An Overview of Blockchain Technology: Architecture, Consensus, and Future Trends. In 2017 IEEE International Congress on Big Data (BigData Congress) (pp. 557-564). IEEE. [4] Iansiti, M., & Lakhani, K. R. (2017). The Truth About Blockchain. Harvard Business Review, 95(1), 118-127. [5] Swan, M. (2015). Blockchain: Blueprint for a New Economy. O'Reilly Media, Inc. [6] Szabo, N. (1997). The Idea of Smart Contracts. Nick Szabo’s Papers and Concise Tutorials. [7] Buterin, V. (2014). A Next-Generation Smart Contract and Decentralized Application Platform. Ethereum White Paper. [8] Christidis, K., & Devetsikiotis, M. (2016). Blockchain and Smart Contracts for the Internet of Things. IEEE Access, 4, 2292-2303. [9] Saberi, S., Kouhizadeh, M., Sarkis, J., & Shen, L. (2019). Blockchain technology and its relationship to sustainable supply chain management. International Journal of Production Research, 57(7), 2117-2135. [10] Kshetri, N. (2018). Blockchain’s roles in meeting key supply chain management objectives. International Journal of Information Management, 39, 80-89. [11] Francisco, K., & Swanson, D. (2018). The Supply Chain Has No Clothes: Technology Adoption of Blockchain for Supply Chain Transparency. Logistics, 2(1), 2. [12] Lee, J. G., & Lee, S. J. (2018). A study on a blockchain-based pharmaceutical supply chain system: Focusing on the verification of forgery and falsification. Journal of Information Technology Applications & Management, 25(4), 1-15. [13] Zhang, Q., & Wen, Q. (2019). Application of blockchain technology in agricultural products supply chain. Transactions of the Chinese Society of Agricultural Engineering, 35(3), 1-8. [14] Tian, F. (2017). A supply chain traceability system for food safety based on HACCP, blockchain & Internet of things. In 2017 International Conference on Service Systems and Service Management (pp. 1-6). IEEE. [15] Caro, M. P., Ali, M. S., Vecchio, M., & Giaffreda, R. (2018). Blockchain-based traceability in agri-food supply chain management: Practical applications. In 2018 IoT Vertical and Topical Summit on Agriculture - Tuscany (IOT Tuscany) (pp. 1-4). IEEE. 130 [16] Nakamoto, S. (2008). Bitcoin: A Peer-to-Peer Electronic Cash System. [17] Tapscott, D., & Tapscott, A. (2016). Blockchain Revolution: How the Technology Behind Bitcoin Is Changing Money, Business, and the World. Penguin. [18] Iansiti, M., & Lakhani, K. R. (2017). The Truth About Blockchain. Harvard Business Review, 95(1), 118-127. [19] Szabo, N. (1997). The Idea of Smart Contracts. Nick Szabo’s Papers and Concise Tutorials. [20] Buterin, V. (2014). A Next-Generation Smart Contract and Decentralized Application Platform. Ethereum White Paper. [21] Christidis, K., & Devetsikiotis, M. (2016). Blockchain and Smart Contracts for the Internet of Things. IEEE Access, 4, 2292-2303. [22] Swan, M. (2015). Blockchain: Blueprint for a New Economy. O'Reilly Media, Inc. [23] Zheng, Z., Xie, S., Dai, H., Chen, X., & Wang, H. (2017). An Overview of Blockchain Technology: Architecture, Consensus, and Future Trends. In 2017 IEEE International Congress on Big Data (BigData Congress) (pp. 557-564). IEEE. [24] Kshetri, N. (2018). Blockchain’s roles in meeting key supply chain management objectives. International Journal of Information Management, 39, 80-89. [25] Francisco, K., & Swanson, D. (2018). The Supply Chain Has No Clothes: Technology Adoption of Blockchain for Supply Chain Transparency. Logistics, 2(1), 2. [26] Saberi, S., Kouhizadeh, M., Sarkis, J., & Shen, L. (2019). Blockchain technology and its relationship to sustainable supply chain management. International Journal of Production Research, 57(7), 2117-2135.