Building the addTransactionToPendingTransactions method 

Next, we need to push the newTransaction that was returned to the pendingTransactions array of the blockchain. Therefore, let's create another method, called addTransactionToPendingTransactions

  1. In the dev/blockchain.js file, the addTransactionToPendingTransactions method will be defined as follows:  
Blockchain.prototype.addTransactionToPendingTransactions = function(transactionObj) {};
  1. Next, take the transactionObj and push it to the pendingTransactions array of the blockchain: 
Blockchain.prototype.addTransactionToPendingTransaction = function(transactionObj) {    this.pendingTransactions.push(transactionObj);};
  1. Then, we simply want to return the index of the block to which the ...

Get Learn Blockchain Programming with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.