We'll build a new method on the blockchain prototype, called getAddressData, and we'll use this method inside of the /address/:address endpoint to fetch the data for a specific address that we are searching for:
- Let's build this new method inside of the blockchain.js file. After the getTransaction method, define the getAddressData method as follows:
Blockchain.prototype.getAddressData = function(address) {
});
- Now, the first thing that we want to do inside of this method is to get all of the transactions that are associated with the address and put them into a single array. Let's define that array now:
Blockchain.prototype.getAddressData = function(address) {
const addressTransactions = [];
});
- Then, we want to cycle through all of the transactions inside of the blockchain. If any of those blocks have the address...