In this section, let's build a new endpoint called /transaction/broadcast. Anytime we want to create a new transaction from now on, we're going to hit this /transaction/broadcast endpoint. This endpoint will do two things:
- It will create a new transaction.
- It will then broadcast that new transaction to all the other nodes in the network.
Let's go through the following steps to create the endpoint:
- To add this endpoint, go to the dev/networkNode.js file where we have defined all the endpoints, and add this new endpoint as follows:
app.post('/transaction/broadcast', function(req, res) ) {
});
- Then, in order for the endpoint to carry out the aforementioned functionalities, add the following highlighted code to the endpoint:
app.post('/transaction/broadcast', function(req, res) ) {
const newTransaction...