Adding a pending transaction to our blockchain 

Now let's try to understand how we can get the pendingTransaction into our actual chain up here. The way we do that is by mining a new block or by creating a new block. Let's do that now:

  1. After we create the newTransaction, let's create a new block using the createNewBlock method, as highlighted in the following code:
const Blockchain = require('./blockchain');const bitcoin = new Blockchain();bitcoin.createNewBlock(789457,'OIUOEDJETH8754DHKD','78SHNEG45DER56');bitcoin.createNewTransaction(100,'ALEXHT845SJ5TKCJ2','JENN5BG5DF6HT8NG9');bitcoin.createNewBlock(548764,'AKMC875E6S1RS9','WPLS214R7T6SJ3G2');console.log(bitcoin);

What we have done is created a block, created a transaction, and then ...

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.