30 minutes ⇒ Level: Low
Introduction to Integration (15 minutes)
- Begin with a concise summary of the project's objective and the current progress, emphasizing that we are now in the crucial stage of connecting and integrating the components.
- Clarify that the initial goal of this integration phase is to link the Raspberry Pi with the smart contract deployed on a local blockchain network. This connection will be facilitated by a main program (Node.js) running on the Raspberry Pi.
- Remind the students that we will utilize the Ethers.js library to interact with the smart contract. They should already be familiar with the basic procedures for reading from and writing to a smart contract, based on the exercises in the preceding section of this course. Encourage students to apply the knowledge gained from these previous exercises.
- Stress the importance of having both the ABI and the address of the smart contract for interacting with it. Additionally, an RPC provider is required to establish communication with the blockchain node. In our scenario, this communication will be with a local node set up in an earlier module.
- Point out that the main program, which will integrate all components, requires an account created on the local blockchain network. Direct students to retrieve the account address from a hardhat node (using the terminal command), which generates several accounts with faucet cryptocurrency for transaction purposes.
- Detail that the second objective of the integration is to devise logic for managing changes in the smart contract's data records on the blockchain network. The main program should either periodically check the blockchain node for updates to the smart contract's state, or utilize events if they have been incorporated into the smart contract. Based on the data records acquired from the blockchain network, the main program should enact the decision-making processes previously designed. For instance, this might involve specifying the conditions under which the print function is triggered to command a 3D printer to start printing a specific product.
Introduction to Testing of the System (15 minutes)
- Inform students that they will conduct tests on their systems following the integration of all components.
- Direct student groups to develop flowcharts depicting user activities within the system for testing purposes, referencing their system designs.
- Specify that a basic test scenario must capture the detection of a state change in the smart contract, followed by the initiation of a printing process on the 3D printer while encouraging the inclusion of extra features to enhance system comprehension.
- Emphasize that testing scenarios can be automated through programming or manually executed via the user interface, and instruct students to identify all essential tools and libraries needed for test scenario implementation.