Building a dapp to interact with the blockchain node
This sample dapp demonstrates a basic interaction with the blockchain node just deployed in the previous steps. For this example, we’ll use Node.js for the application backend and React.js for the frontend. The dapp implements the backend logic in the app.js
file using Node.js and the Express (https://expressjs.com/) web framework, while the blockchain logic resides in the blockchain.js
file. The frontend is created using React.js, which allows the user to add new blocks to the blockchain by entering data in the input field and clicking the Add Block button. The source code implementation is kept simple in the book for illustrative purposes. The full source code can be found in the GitHub repository for this chapter, available at https://github.com/PacktPublishing/Developing-Blockchain-Solutions-in-the-Cloud/tree/main/Chapter11.
Please save this JavaScript code in an app.js
file. This script first obtains a list of existing...