Building the createNewBlock method

Let's continue with building our blockchain data structure. After defining our constructor function in the previous section, the next thing that we want to do with our constructor function is to place a method in our Blockchain function. This method that we are going to create will be called createNewBlock. As its name suggests, this method will create a new block for us. Let's follow the below mentioned steps to build the method: 

  1. The createNewBlock method will be defined as follows: 
Blockchain.prototype.createNewBlock = function () { }
  1. Now we've got this createNewBlock  method on our blockchain prototype object. This method will take the three parameters, as highlighted in the following line of code:  ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.